Commit 53c6289fce for openssl.org

commit 53c6289fce28b73c3ed383819625440771f6df95
Author: slontis <shane.lontis@oracle.com>
Date:   Wed Sep 23 16:46:22 2026 +1000

    Fix: CI Failure

    The following commit https://github.com/openssl/openssl/commit/b2f2f7fea96415a92d8481c8dc6b413dd3f63f8e
    exposes a side effect that causes a segfault in sslapitest.

    sslapittest is a static, and loads the DASYNC engine as a shared library.
    The callstack on failure is:
    dasync_destroy()
      ERR_unload_strings()
        CRYPTO_THREAD_write_lock()  ← SIGSEGV

    This happens because the cleanup order is such that the err_cleanp() is called first
    which frees the lock and sets err_string_lock = NULL
    Then it later calls ERR_unload_string() which will crash on the write_lock()

    The above commit does a call early to ERR_set_mark() which changes the cleanup order.

    Assisted-by: OpenAI Codex:gpt-5.6-sol
    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Milan Broz <mbroz@openssl.org>
    Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Norbert Pocs <norbertp@openssl.org>
    Merge-date: Wed Sep 23 18:37:17 2026
    Merged-from: https://github.com/openssl/openssl/pull/32943

diff --git a/crypto/err/err.c b/crypto/err/err.c
index e945f7c860..2923f0b13f 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -302,6 +302,10 @@ int ERR_unload_strings(int lib, ERR_STRING_DATA *str)
     if (!RUN_ONCE(&err_string_init, do_err_strings_init))
         return 0;

+    /* The error string table may already have been cleaned up. */
+    if (err_string_lock == NULL)
+        return 1;
+
     if (!CRYPTO_THREAD_write_lock(err_string_lock))
         return 0;
     /*