We have service using openSSL
version 1.0.2h
in multi threaded environment.
First thread runs blocking read, the other one is doing periodical writes.
It crashes from time to time somewhere inside libssl.so
in SSL_write
function. Code calling SSL_write
looks absolutely legal, it operates with buffer allocated on stack of the calling function. Also crash is very rare which suggests it might be race condition.
I found the following article saying that using a single SSL
object in two threads, one each for reading and writing is not safe, though CRYPTO_set_locking_callback
is set. Is that correct? If yes, than what is the suggested way to resolve this? If I block mutex
on a blocking read, I will not able to write.