I am using
http://www.openssl.org/docs/crypto/threads.html
to make crypto library thread safe. It is working find if I am linking with static library of libssl and libcrypto.
But if I am linking with dynamic version of the library and running multiple instance of the binary it is crashing.
How to fix this issue ?
Edit
Program is always crashing at
#0 0x00007f9f42257be5 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#1 0x00007f9f4225820c in lh_retrieve () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#2 0x00007f9f4225ac8e in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#3 0x00007f9f4225bb41 in ERR_get_state () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#4 0x00007f9f4225c886 in ERR_clear_error () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#5 0x00007f9f44df496c in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#6 0x00007f9f44df6015 in Curl_ossl_connect () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#7 0x00007f9f44e0a349 in Curl_ssl_connect () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#8 0x00007f9f44de0950 in Curl_http_connect () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#9 0x00007f9f44df12ba in Curl_protocol_connect () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#10 0x00007f9f44df15b0 in Curl_connect () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
But while linking with static version, It is not crashing
Another bt
#0 0x00007f57a01b1be5 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#1 0x00007f57a01b20bf in lh_delete () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#2 0x00007f57a01b45b3 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#3 0x00007f57a01b5a5a in ERR_remove_thread_state () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#4 0x00007f57a2d4ffbb in Curl_ossl_close_all () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#5 0x00007f57a2d47742 in Curl_close () from /usr/lib/x86_64-linux-gnu/libcurl.so.4