Skip to content

1.1.0g: test_shlibload fails on AIX #5485

@makr

Description

@makr

Hello OpenSSL-team!

I am checking test_shlibload failures on AIX. All test cases dump a core with SIGILL. I already played around with the sources for quite some time and am confident now, that it has to do with OPENSSL_cleanup() is not removed as atexit() handler.
I added a number of OPENSSL_INIT_DEBUG outputs. Now when I remove the dlclose()-call the test cases succeed and the output shows that OPENSSL_cleanup() is called after shlibtest's main() returns:

bash-4.2$ ../util/shlib_wrap.sh ./shlibloadtest -just_crypto libcrypto.so libssl.so                          
OPENSSL_INIT: ossl_init_base: Setting up stop handlers
OPENSSL_INIT: ossl_init_base: Registering cleanup exit handler
OPENSSL_INIT: ossl_init_thread_start: marking thread for err_state
OPENSSL_INIT: ossl_init_load_crypto_strings: err_load_crypto_strings_int()
OPENSSL_INIT: ossl_init_thread_start: marking thread for err_state
Success
OPENSSL_INIT: OPENSSL_cleanup: function entered
OPENSSL_INIT: ossl_init_thread_stop: err_delete_thread_state()
OPENSSL_INIT: OPENSSL_cleanup: err_free_strings_int()
OPENSSL_INIT: OPENSSL_cleanup: rand_cleanup_int()
OPENSSL_INIT: OPENSSL_cleanup: conf_modules_free_int()
OPENSSL_INIT: OPENSSL_cleanup: engine_cleanup_int()
OPENSSL_INIT: OPENSSL_cleanup: crypto_cleanup_all_ex_data_int()
OPENSSL_INIT: OPENSSL_cleanup: bio_sock_cleanup_int()
OPENSSL_INIT: OPENSSL_cleanup: bio_cleanup()
OPENSSL_INIT: OPENSSL_cleanup: evp_cleanup_int()
OPENSSL_INIT: OPENSSL_cleanup: obj_cleanup_int()
OPENSSL_INIT: OPENSSL_cleanup: err_cleanup()

This behavior is problematic on AIX, at least. On AIX the dlclose() behavior is documented as follows:

Modules being unloaded with the dlclose subroutine will not be removed from the process's address space if they are still required by other modules. Nevertheless, subsequent uses of Data are invalid,
and further uses of symbols that were exported by the module being unloaded result in undefined behavior.

The stack trace in the core dump shows that exit() is trying to invoke a function at 0x0.

My opinion here is that a library that is supposed to be dynamically loaded (and unloaded) should not register atexit() handlers, but declare init/fini or constructor/destructor functions instead.

I'll play around with it tomorrow, but maybe someone has another opinion meanwhile.

kind regards
-- Matthias

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions