From a5688d4dc2ec46540c8a33617bc42dc30f10920e Mon Sep 17 00:00:00 2001 From: apbassett <43486400+apbassett@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:28:12 -0400 Subject: [PATCH] Refactors timeouts to print stack traces --- .github/workflows/build.yml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f04fc88..2cba173 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -99,9 +99,31 @@ jobs: echo "Note: output is supressed due to length. See build artifacts for full logs." echo "Running..." - # Capture GDB output (15 minute timeout) - gdb_output=$(timeout 900 gdb -batch -ex run -ex backtrace --args ./amalgam${{ matrix.amlg-postfix }} --debug-internal-memory tic_tac_toe_evolver.amlg -target-time 300) + # Run Evolver with GDB + # However, sent a SIGINT after 6 minutes (indicating a hanging Evolver) to get a stacktrace + TIMEOUT=360 + + # Run GDB in the background + gdb_output_file=$(mktemp) + if [[ "${{ matrix.amlg-postfix }}" == *"mt"* ]]; then + gdb -batch -ex run -ex "thread apply all bt" --args ./amalgam${{ matrix.amlg-postfix }} --debug-internal-memory tic_tac_toe_evolver.amlg -target-time 300 > "$gdb_output_file" 2>&1 & + GDB_PID=$! + else + gdb -batch -ex run -ex bt --args ./amalgam${{ matrix.amlg-postfix }} --debug-internal-memory tic_tac_toe_evolver.amlg -target-time 300 > "$gdb_output_file" 2>&1 & + GDB_PID=$! + fi + + echo "GDB PID: $GDB_PID" + + # Set up a timer to send SIGINT to GDB after the timeout + { + sleep $TIMEOUT + kill -SIGINT $GDB_PID + } & + wait $GDB_PID gdb_exit_code=$? + gdb_output=$(cat "$gdb_output_file") + # Save output to logs.txt, uploaded later echo "$gdb_output" >> logs.txt # Evaluate GDB exit code and exit this workflow accordingly @@ -117,7 +139,7 @@ jobs: fi else # If GDB exited with code 0, there was a segfault - echo "$gdb_output" | tail -n 200 + echo "$gdb_output" | tail -n 400 exit 139 fi