Ensure that libcrypto and libssl do not unload until the process exits
authorMatt Caswell <matt@openssl.org>
Tue, 18 Oct 2016 13:13:25 +0000 (14:13 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 2 Nov 2016 23:32:50 +0000 (23:32 +0000)
commit5836780f436e03be231ff245f04f2f9f2f0ede91
treee9ff7f34263a68d9749f59926cf194acd7d8eea5
parentb39eda7ee69a9277c722f8789736e00dc680cda6
Ensure that libcrypto and libssl do not unload until the process exits

Because we use atexit() to cleanup after ourselves, this will cause a
problem if we have been dynamically loaded and then unloaded again: the
atexit() handler may no longer be there.

Most modern atexit() implementations can handle this, however there are
still difficulties if libssl gets unloaded before libcrypto, because of
the atexit() callback that libcrypto makes to libssl.

The most robust solution seems to be to ensure that libcrypto and libssl
never unload. This is done by simply deliberately leaking a dlopen()
reference to them.

Reviewed-by: Tim Hudson <tjh@openssl.org>
crypto/init.c