[lldb][Windows] Dump thread stacks before lit's timeout kills a test - #213239
[lldb][Windows] Dump thread stacks before lit's timeout kills a test#213239charles-zablit wants to merge 2 commits into
Conversation
|
@llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) ChangesOn Windows, when a test hits a timeout, we currently don't get a stacktrace. dotest solves this on POSIX: it registers a SIGTERM handler, so a killed test prints its stack. The handler does not run on Windows however because This patch adds BeforeThere is no stacktrace. AfterFull diff: https://github.com/llvm/llvm-project/pull/213239.diff 1 Files Affected:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 604fb98b1e2e5..3c966dceb96c7 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -504,6 +504,19 @@ def registerFaulthandler():
if getattr(faulthandler, "register", None):
faulthandler.register(signal.SIGTERM, chain=True)
+ if sys.platform != "win32":
+ return
+
+ # lit kills a hung test with TerminateProcess on Windows, so the SIGTERM
+ # handler above never runs and a timeout is reported with no indication of
+ # where it hung. Dump every thread's stack while the process is still alive.
+ try:
+ secs = float(os.environ.get("LLDB_TEST_STACK_DUMP_SECS", 300))
+ except ValueError:
+ secs = 300
+ if secs > 0:
+ faulthandler.dump_traceback_later(secs, exit=False)
+
def setupSysPath():
"""
|
| try: | ||
| secs = float(os.environ.get("LLDB_TEST_STACK_DUMP_SECS", 300)) | ||
| except ValueError: | ||
| secs = 300 |
There was a problem hiding this comment.
We should not hardcode any timeouts let alone in different places. Would it be possible to derive this from the per-test timeout setting?
There was a problem hiding this comment.
Done through a new argument in the dotest invocation.
On Windows, when a test hits a timeout, we currently don't get a stacktrace. dotest solves this on POSIX: it registers a SIGTERM handler, so a killed test prints its stack. The handler does not run on Windows however because
faulthandler.registerdoesn't exist there, and lit terminates the process instead of signalling it (no signals on Windows).This patch adds
faulthandler.dump_traceback_later()with a default timeout value of 300s. That's longer than the longest test in CI (~150s) and does not kill the test. It simply dumps the stacktrace at a point where the test is very likely stuck.Before
There is no stacktrace.
After