Skip to content

Commit

Permalink
GH-452 Update threads test to avoid crash on exit.
Browse files Browse the repository at this point in the history
OpenSSL 3.0 added atexit() handler that appears to cause crashes with test
62_threads-ctx_new-deadlock.t.

The test is now updated to initialise OpenSSL libcrypto so that atexit()
handler is not called. As a result, OpenSSL libraries are no longer cleaned up
on exit. This is fine for the test since the process that runs it is already
exiting and the test requires no special cleaning up.
  • Loading branch information
h-vn committed Dec 27, 2023
1 parent cc3cd24 commit 008b235
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions t/local/62_threads-ctx_new-deadlock.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,27 @@ if (not can_thread()) {

require threads;

initialise_libssl();
# OpenSSL 3.0 and later set atexit() handlers in such a way that this
# test may crash during the default cleanup on exit. See
# https://github.com/openssl/openssl/issues/17469 and
# https://github.com/radiator-software/p5-net-ssleay/issues/452 for
# more information, including workarounds when OPENSSL_INIT_crypto()
# is not available in Net::SSLeay.
#
# If we need to do OPENSSL_INIT_crypto() call, we must skip the
# default library initialisation. Otherwise our call to
# OPENSSL_init_crypto() won't do anything.
defined &Net::SSLeay::OPENSSL_init_crypto ?
Net::SSLeay::OPENSSL_init_crypto(Net::SSLeay::OPENSSL_INIT_NO_ATEXIT(), undef) :
initialise_libssl();

my $start_time = time;

#exit the whole program if it runs too long
threads->new( sub { sleep 20; warn "FATAL: TIMEOUT!"; exit } )->detach;

#print STDERR "Gonna start multi-threading part\n";
threads->new(\&do_check) for (1..20);
threads->new(\&do_check) for (1..100);

#print STDERR "Waiting for all threads to finish\n";
do_sleep(50) while (threads->list());
Expand Down

0 comments on commit 008b235

Please sign in to comment.