Skip to content

Commit

Permalink
Refactors timeouts to print stack traces
Browse files Browse the repository at this point in the history
  • Loading branch information
apbassett committed Aug 8, 2024
1 parent 85f109d commit a5688d4
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a5688d4

Please sign in to comment.