hiroyuki-sato commented on code in PR #51121:
URL: https://github.com/apache/arrow/pull/51121#discussion_r3909961378


##########
cpp/build-support/run-test.sh:
##########
@@ -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 [[ "${COREFILES[0]}" == *\* ]]; then
+    COREFILES=()
   fi
+
+  for COREPATH in "${COREFILES[@]}"; do
+    if [ ! -e "${COREPATH}" ]; then

Review Comment:
   Before running the debugger, check whether the file still exists. If it has 
already been deleted, print a message and continue with the next file.
   
   There is still a small chance that the file could be deleted between 
checking its existence and running `lldb`/`gdb`, but I don't think we can 
reasonably handle that race condition in a shell script, so I think this is an 
acceptable compromise.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to