Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21162: Refactors timeout implementation to print stack traces #12

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
amlg-postfix: ['-st', '-mt-afmi']
amlg-postfix: ['-st-afmi', '-mt-afmi']

steps:

Expand Down Expand Up @@ -99,26 +99,42 @@ 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)
gdb_exit_code=$?
# 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_output=$(cat "$gdb_output_file")

# Save output to logs.txt, uploaded later
echo "$gdb_output" >> logs.txt

# Print a reasonable amount of the logs to the console
echo "$gdb_output" | tail -n 400

# Evaluate GDB exit code and exit this workflow accordingly
if [[ $gdb_exit_code -ne 0 ]]; then
echo "GDB has exited"
echo "$gdb_output" | tail -n 6
# If GDB exited with an error but the test process passed, exit 0
if echo "$gdb_output" | tail -n 6 | grep -q "exited normally"; then
exit 0
# Else, the test process failed, exit 1
else
exit 1
fi
if echo "$gdb_output" | tail -n 100 | grep -q "exited normally"; then
exit 0
# Else, something failed, exit 1
else
# If GDB exited with code 0, there was a segfault
echo "$gdb_output" | tail -n 200
exit 139
exit 1
fi

- name: Compress 'evolve' directory
Expand Down