1.1.1b crash (RUN_ONCE problem?)

Viktor Dukhovni openssl-users at dukhovni.org
Tue Mar 5 04:41:36 UTC 2019

> On Mar 4, 2019, at 11:29 PM, Norm Green <norm.green at gemtalksystems.com> wrote:
> Yes I'm sure the build process is correct.
> Turns out this problem was cause by one thread calling exit() while another thread was doing SSL_write().  The SSL exit handler triggered by exit() was causing the lock in question to be freed AFAIKT.
> So it would seem that threads either need to exit with pthread_exit() or return to a known state such that no SSL calls are in progress in any thread before the process can safely exit().

Yes, main() must not exit while threads are running code from
libraries with exit handlers.  This is issue is not unique to
OpenSSL.  I've observed the same problem with threading running
code in MIT's GSSAPI library.

Some users want libraries to be unloadable without memory leaks,
others want safe exit() while threads are running...  Serving
both is hard.

A multi-threaded program that wants to exit before all the
threads are done, should probably call _exit(), and skip
the exit handlers (when none of those are doing anything
critical, like flushing stdio buffers).

Alternatively arrange for a way to ask threads to terminate
promptly, and wait for them to do that.


More information about the openssl-users mailing list