From cb1bac4dfdb1811a0ed06d26409d6474c6160ef4 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Thu, 30 Apr 2026 02:56:48 -0700 Subject: [PATCH 1/2] Skip stack trace if gdb is unavailable --- ci/timeout_with_stack.py | 51 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/ci/timeout_with_stack.py b/ci/timeout_with_stack.py index c38f729f0..994c51a74 100644 --- a/ci/timeout_with_stack.py +++ b/ci/timeout_with_stack.py @@ -23,6 +23,7 @@ import argparse import os +import shutil import signal import subprocess import sys @@ -109,26 +110,38 @@ def capture_stack_trace(pid: int, stack_type=StackType.C) -> None: else: bt_command = "thread apply all py-bt" print(f"\nCapturing Python stack trace for process {pid}:") - proc = subprocess.run( - [ - "gdb", - "--quiet", - "--pid", - str(pid), - "-ex", - "set pagination off", - "-ex", - "set confirm off", - "-ex", - bt_command, - "-ex", - "quit", - ], - capture_output=True, - text=True, - check=False, - ) + gdb = shutil.which("gdb") + if gdb is None: + print(f"Skipping stack trace for process {pid}: gdb not found") + return + + try: + proc = subprocess.run( + [ + gdb, + "--quiet", + "--pid", + str(pid), + "-ex", + "set pagination off", + "-ex", + "set confirm off", + "-ex", + bt_command, + "-ex", + "quit", + ], + capture_output=True, + text=True, + check=False, + ) + except FileNotFoundError: + print(f"Skipping stack trace for process {pid}: gdb not found") + return + print(proc.stdout) + if proc.stderr: + print(proc.stderr, file=sys.stderr) def capture_all_stacks(pid: int, *, enable_python: bool = False) -> None: From 9149fbcc937ac21e6eac9d3598e5b9f23eea8932 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Tue, 12 May 2026 11:49:50 -0700 Subject: [PATCH 2/2] Do not raise FileNotFoundError when gdb is not found --- ci/timeout_with_stack.py | 42 ++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/ci/timeout_with_stack.py b/ci/timeout_with_stack.py index 994c51a74..d2dfa700a 100644 --- a/ci/timeout_with_stack.py +++ b/ci/timeout_with_stack.py @@ -115,29 +115,25 @@ def capture_stack_trace(pid: int, stack_type=StackType.C) -> None: print(f"Skipping stack trace for process {pid}: gdb not found") return - try: - proc = subprocess.run( - [ - gdb, - "--quiet", - "--pid", - str(pid), - "-ex", - "set pagination off", - "-ex", - "set confirm off", - "-ex", - bt_command, - "-ex", - "quit", - ], - capture_output=True, - text=True, - check=False, - ) - except FileNotFoundError: - print(f"Skipping stack trace for process {pid}: gdb not found") - return + proc = subprocess.run( + [ + gdb, + "--quiet", + "--pid", + str(pid), + "-ex", + "set pagination off", + "-ex", + "set confirm off", + "-ex", + bt_command, + "-ex", + "quit", + ], + capture_output=True, + text=True, + check=False, + ) print(proc.stdout) if proc.stderr: