lib-ssl-iostream: Don't call OPENSSL_cleanup() for openssl 4.0#295
Open
hector-cao wants to merge 1 commit into
Open
lib-ssl-iostream: Don't call OPENSSL_cleanup() for openssl 4.0#295hector-cao wants to merge 1 commit into
hector-cao wants to merge 1 commit into
Conversation
With OpenSSL 4.0 the lib-dcrypt unit tests (test-crypto, test-stream) segfault at process exit. dovecot_openssl_common_global_ref() installs custom OpenSSL memory functions via CRYPTO_set_mem_functions(); their code lives inside the dynamically loaded OpenSSL/dcrypt module. It also passes OPENSSL_INIT_NO_ATEXIT so that libcrypto does not register its own atexit(OPENSSL_cleanup) handler. dovecot_openssl_common_global_unref() then called OPENSSL_cleanup() explicitly. On OpenSSL 4.0 this explicit cleanup re-arms an internal exit-time cleanup that runs after main() returns [1], i.e. after the module (and therefore the custom memory functions) has been dlclose()d, so libcrypto calls the now-unmapped free() function and the process crashes with SIGSEGV. [1] https://openssl-library.org/post/2026-03-10-remove-atexit/index.html Signed-off-by: Hector Cao <hector.cao@canonical.com>
Contributor
|
Thanks, we'll take a look. |
Contributor
|
Hi, your explanation sounds bit counter to the blog post you pointed out, which says that atexit handler is not registered ever. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With OpenSSL 4.0 the lib-dcrypt unit tests (test-crypto, test-stream) segfault at process exit.
dovecot_openssl_common_global_ref() installs custom OpenSSL memory functions via CRYPTO_set_mem_functions(); their code lives inside the dynamically loaded OpenSSL/dcrypt module. It also passes OPENSSL_INIT_NO_ATEXIT so that libcrypto does not register its own atexit(OPENSSL_cleanup) handler.
dovecot_openssl_common_global_unref() then called OPENSSL_cleanup() explicitly. On OpenSSL 4.0 this explicit cleanup re-arms an internal exit-time cleanup that runs after main() returns [1], i.e. after the module (and therefore the custom memory functions) has been dlclose()d, so libcrypto calls the now-unmapped free() function and the process crashes with SIGSEGV.
[1] https://openssl-library.org/post/2026-03-10-remove-atexit/index.html