From 90f2e0c60ac3d457b6498686ef5db3b0488a13c1 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Tue, 1 Sep 2026 21:21:41 +0900 Subject: [PATCH 1/8] GH-51095: [CI][C++] Fix core file detection in run-test.sh --- cpp/build-support/run-test.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index ae39bef6714..10dc843e38f 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -139,19 +139,30 @@ function print_coredumps() { FILENAME=$(basename "${TEST_EXECUTABLE}") FILENAME=$(echo "${FILENAME}" | cut -c-15) - COREFILES=$(find /tmp -maxdepth 1 -type f -name "core.${FILENAME}*" -exec basename {} \;) - if [ -n "$COREFILES" ]; then - for COREFILE in $COREFILES; do - COREPATH="/tmp/${COREFILE}" + # Use read instead of mapfile because macOS uses Bash 3.2. + # A trailing slash is required to follow the /tmp symbolic link on macOS. + COREFILES=() + while IFS= read -r COREFILE; do + COREFILES+=("$COREFILE") + done < <( + find /tmp/ -maxdepth 1 -type f -name "core.${FILENAME}*" + ) + + if [ "${#COREFILES[@]}" -gt 0 ]; then + for COREPATH in "${COREFILES[@]}"; do echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "Running '${TEST_EXECUTABLE}' produced core dump at '${COREPATH}', printing backtrace:" + # Print backtrace if [ "$(uname)" == "Darwin" ]; then lldb -c "${COREPATH}" --batch --one-line "thread backtrace all -e true" else - gdb -c "${COREPATH}" "$TEST_EXECUTABLE" -ex "thread apply all bt" -ex "set pagination 0" -batch + gdb -c "${COREPATH}" "$TEST_EXECUTABLE" \ + -ex "thread apply all bt" -ex "set pagination 0" -batch fi + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + # Remove the coredump, it can be regenerated via running the test case directly rm "${COREPATH}" done From e69e3e078abf0457348bad282e89d527efd447d3 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 09:03:12 +0900 Subject: [PATCH 2/8] Revert "GH-51095: [CI][C++] Fix core file detection in run-test.sh" This reverts commit 90f2e0c60ac3d457b6498686ef5db3b0488a13c1. --- cpp/build-support/run-test.sh | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index 10dc843e38f..ae39bef6714 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -139,30 +139,19 @@ function print_coredumps() { FILENAME=$(basename "${TEST_EXECUTABLE}") FILENAME=$(echo "${FILENAME}" | cut -c-15) - # Use read instead of mapfile because macOS uses Bash 3.2. - # A trailing slash is required to follow the /tmp symbolic link on macOS. - COREFILES=() - while IFS= read -r COREFILE; do - COREFILES+=("$COREFILE") - done < <( - find /tmp/ -maxdepth 1 -type f -name "core.${FILENAME}*" - ) - - if [ "${#COREFILES[@]}" -gt 0 ]; then - for COREPATH in "${COREFILES[@]}"; do + COREFILES=$(find /tmp -maxdepth 1 -type f -name "core.${FILENAME}*" -exec basename {} \;) + if [ -n "$COREFILES" ]; then + for COREFILE in $COREFILES; do + COREPATH="/tmp/${COREFILE}" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "Running '${TEST_EXECUTABLE}' produced core dump at '${COREPATH}', printing backtrace:" - # Print backtrace if [ "$(uname)" == "Darwin" ]; then lldb -c "${COREPATH}" --batch --one-line "thread backtrace all -e true" else - gdb -c "${COREPATH}" "$TEST_EXECUTABLE" \ - -ex "thread apply all bt" -ex "set pagination 0" -batch + gdb -c "${COREPATH}" "$TEST_EXECUTABLE" -ex "thread apply all bt" -ex "set pagination 0" -batch fi - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - # Remove the coredump, it can be regenerated via running the test case directly rm "${COREPATH}" done From 067cac6d72a4c9d752ffdbcf3357b60fe52f803c Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 09:17:54 +0900 Subject: [PATCH 3/8] GH-51095: [CI][C++] Fix core file detection in run-test.sh --- cpp/build-support/run-test.sh | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index ae39bef6714..b284492be2a 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -119,6 +119,7 @@ function run_test() { } function print_coredumps() { + STATUS=0 # The script expects core files relative to the build directory with unique # names per test executable because of the parallel running. So the corefile # patterns must be set with prefix `core.{test-executable}*`: @@ -139,23 +140,33 @@ function print_coredumps() { FILENAME=$(basename "${TEST_EXECUTABLE}") FILENAME=$(echo "${FILENAME}" | cut -c-15) - COREFILES=$(find /tmp -maxdepth 1 -type f -name "core.${FILENAME}*" -exec basename {} \;) - if [ -n "$COREFILES" ]; then - for COREFILE in $COREFILES; do - COREPATH="/tmp/${COREFILE}" - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Running '${TEST_EXECUTABLE}' produced core dump at '${COREPATH}', printing backtrace:" - # Print backtrace - if [ "$(uname)" == "Darwin" ]; then - lldb -c "${COREPATH}" --batch --one-line "thread backtrace all -e true" - else - gdb -c "${COREPATH}" "$TEST_EXECUTABLE" -ex "thread apply all bt" -ex "set pagination 0" -batch - fi - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - # Remove the coredump, it can be regenerated via running the test case directly - rm "${COREPATH}" - done + COREFILES=(/tmp/"core.${FILENAME}"*) + # Clear the array if no core files match the pattern. + if [ ! -e "${COREFILES[0]}" ]; then + COREFILES=() fi + + for COREPATH in "${COREFILES[@]}"; do + if [ ! -e "${COREPATH}" ]; then + echo "Core file '${COREPATH}' no longer exists. It may have been removed by another process." + continue + fi + + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "Running '${TEST_EXECUTABLE}' produced core dump at '${COREPATH}', printing backtrace:" + # Print backtrace + if [ "$(uname)" == "Darwin" ]; then + lldb -c "${COREPATH}" --batch --one-line "thread backtrace all -e true" + else + gdb -c "${COREPATH}" "$TEST_EXECUTABLE" -ex "thread apply all bt" -ex "set pagination 0" -batch + fi + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + # Remove the coredump, it can be regenerated via running the test case directly + rm "${COREPATH}" + + # Fail the CI if lldb or gdb was run. + STATUS=1 + done } function post_process_tests() { From ce8a351c7d2c59a147855eba91c611566ff1971f Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 09:50:57 +0900 Subject: [PATCH 4/8] GH-51095: [CI][C++] Fix core file detection in run-test.sh --- cpp/build-support/run-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index b284492be2a..92b44347a36 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -142,7 +142,7 @@ function print_coredumps() { COREFILES=(/tmp/"core.${FILENAME}"*) # Clear the array if no core files match the pattern. - if [ ! -e "${COREFILES[0]}" ]; then + if [[ "${COREFILES[0]}" == *\* ]]; then COREFILES=() fi From 46779ad867312be1e83e5fda2f18aac89a9792cf Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 11:39:59 +0900 Subject: [PATCH 5/8] Update cpp/build-support/run-test.sh Co-authored-by: Sutou Kouhei --- cpp/build-support/run-test.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index 92b44347a36..a928cd6b62f 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -140,13 +140,7 @@ function print_coredumps() { FILENAME=$(basename "${TEST_EXECUTABLE}") FILENAME=$(echo "${FILENAME}" | cut -c-15) - COREFILES=(/tmp/"core.${FILENAME}"*) - # Clear the array if no core files match the pattern. - if [[ "${COREFILES[0]}" == *\* ]]; then - COREFILES=() - fi - - for COREPATH in "${COREFILES[@]}"; do + for COREPATH in "/tmp/core.${FILENAME}"*; do if [ ! -e "${COREPATH}" ]; then echo "Core file '${COREPATH}' no longer exists. It may have been removed by another process." continue From 997a1604e7ee33faf8e424b0f02b390fc402247a Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 11:50:22 +0900 Subject: [PATCH 6/8] GH-51095: [CI][C++] Fix core file detection in run-test.sh --- cpp/build-support/run-test.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index a928cd6b62f..5c2f773133b 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -119,7 +119,6 @@ function run_test() { } function print_coredumps() { - STATUS=0 # The script expects core files relative to the build directory with unique # names per test executable because of the parallel running. So the corefile # patterns must be set with prefix `core.{test-executable}*`: @@ -141,6 +140,11 @@ function print_coredumps() { FILENAME=$(echo "${FILENAME}" | cut -c-15) for COREPATH in "/tmp/core.${FILENAME}"*; do + # Skip if the glob did not match any core files. + if [[ "${COREPATH}" == *\* ]]; then + continue + fi + if [ ! -e "${COREPATH}" ]; then echo "Core file '${COREPATH}' no longer exists. It may have been removed by another process." continue @@ -158,8 +162,6 @@ function print_coredumps() { # Remove the coredump, it can be regenerated via running the test case directly rm "${COREPATH}" - # Fail the CI if lldb or gdb was run. - STATUS=1 done } @@ -205,7 +207,9 @@ if [ "$RUN_TYPE" = "test" ]; then post_process_tests fi -print_coredumps +if [ "$STATUS" -ne 0 ] ; then + print_coredumps +fi popd rm -Rf "$TEST_WORKDIR" From a75d6316f3da1ce3d098ab4e3548275e34f311a1 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 13:16:37 +0900 Subject: [PATCH 7/8] Remove space --- cpp/build-support/run-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index 5c2f773133b..ffba61c4d16 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -207,7 +207,7 @@ if [ "$RUN_TYPE" = "test" ]; then post_process_tests fi -if [ "$STATUS" -ne 0 ] ; then +if [ "$STATUS" -ne 0 ]; then print_coredumps fi From 423ba0a4e474b614c680a08c078bb09d329a8c89 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 2 Sep 2026 15:25:30 +0900 Subject: [PATCH 8/8] Update cpp/build-support/run-test.sh Co-authored-by: Sutou Kouhei --- cpp/build-support/run-test.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh index ffba61c4d16..9ccec11b79b 100755 --- a/cpp/build-support/run-test.sh +++ b/cpp/build-support/run-test.sh @@ -140,13 +140,8 @@ function print_coredumps() { FILENAME=$(echo "${FILENAME}" | cut -c-15) for COREPATH in "/tmp/core.${FILENAME}"*; do - # Skip if the glob did not match any core files. - if [[ "${COREPATH}" == *\* ]]; then - continue - fi - + # Skip if the glob did not match any core files or the core file has been removed by another process. if [ ! -e "${COREPATH}" ]; then - echo "Core file '${COREPATH}' no longer exists. It may have been removed by another process." continue fi