Commit 668dc66f66 for openssl.org

commit 668dc66f663729e13988da2222883e09be50b668
Author: Bob Beck <beck@openssl.org>
Date:   Tue Aug 18 18:55:16 2026 -0600

    Add core dumps and matching binary to CI artifacts on linux

    If we manage to have a test crash, let's get the core and
    binary in the artifacts

    I mostly want this for https://github.com/openssl/openssl/pull/32424
    but it has other uses.

    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Norbert Pocs <norbertp@openssl.org>
    MergeDate: Fri Sep 11 19:22:23 2026
    (Merged from https://github.com/openssl/openssl/pull/32425)

diff --git a/.github/workflows/make-test b/.github/workflows/make-test
index c38d0de343..3203fae86c 100755
--- a/.github/workflows/make-test
+++ b/.github/workflows/make-test
@@ -17,6 +17,18 @@ fi
 mkdir -p "$OSSL_CI_ARTIFACTS_PATH"
 export OSSL_CI_ARTIFACTS_PATH="$(cd "$OSSL_CI_ARTIFACTS_PATH"; pwd)"

+# Enable core dumps so a crashing test leaves a core with every thread's stack
+# for diagnosis. Only a failing run produces one; green runs dump nothing.
+# Linux only for now; best effort - a runner that disallows this just won't
+# dump.
+if [ "$(uname)" = Linux ]; then
+    ulimit -c unlimited 2>/dev/null || true
+    if command -v sudo >/dev/null 2>&1; then
+        sudo mkdir -p /tmp/cores && sudo chmod 1777 /tmp/cores || true
+        echo '/tmp/cores/core.%e.%p' | sudo tee /proc/sys/kernel/core_pattern >/dev/null 2>&1 || true
+    fi
+fi
+
 # Run the tests. This might fail, but we need to capture artifacts anyway.
 set +e
 make test HARNESS_JOBS=${HARNESS_JOBS:-4} LHASH_WORKERS=${LHASH_WORKERS:-16} "$@"
@@ -31,6 +43,18 @@ for test_name in quic_multistream; do
     fi
 done

+# Collect any core dumps together with the matching test binary, so the core is
+# usable with gdb without a rebuild. The executable name is the %e field of the
+# core file name. Only a failing run produces any. Linux only for now.
+if [ "$(uname)" = Linux ]; then
+    for core in /tmp/cores/core.*; do
+        [ -f "$core" ] || continue
+        exe=$(basename "$core"); exe=${exe#core.}; exe=${exe%.*}
+        [ -f "test/$exe" ] && cp "test/$exe" "$OSSL_CI_ARTIFACTS_PATH/" || true
+        mv "$core" "$OSSL_CI_ARTIFACTS_PATH/" || true
+    done
+fi
+
 # Log the artifact tree.
 echo "::group::List of artifact files generated"
 echo "Test suite exited with $RESULT, artifacts path is $OSSL_CI_ARTIFACTS_PATH"