This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new a62870ce4c GH-51095: [CI][C++] Fix core file detection in run-test.sh
(#51121)
a62870ce4c is described below
commit a62870ce4c7a7c9b570fbb5d1376cb482f144659
Author: Hiroyuki Sato <[email protected]>
AuthorDate: Wed Sep 2 17:35:34 2026 +0900
GH-51095: [CI][C++] Fix core file detection in run-test.sh (#51121)
### Rationale for this change
In #50934, `find` was used instead of `(ls /tmp | grep $PATTERN)` to find
core files in a ShellCheck-safe way, but using find can cause a race condition
when files or directories under `/tmp` are removed by another process while
find is scanning the directory.
### What changes are included in this PR?
This change uses shell globbing instead of find to avoid this issue.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
No.
* GitHub Issue: #51095
Lead-authored-by: Hiroyuki Sato <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/build-support/run-test.sh | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/cpp/build-support/run-test.sh b/cpp/build-support/run-test.sh
index ae39bef671..9ccec11b79 100755
--- a/cpp/build-support/run-test.sh
+++ b/cpp/build-support/run-test.sh
@@ -139,23 +139,25 @@ 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
- fi
+ for COREPATH in "/tmp/core.${FILENAME}"*; do
+ # Skip if the glob did not match any core files or the core file has been
removed by another process.
+ if [ ! -e "${COREPATH}" ]; then
+ 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}"
+
+ done
}
function post_process_tests() {
@@ -200,7 +202,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"