summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPeter Bierma <zintensitydev@gmail.com>2025-01-02 18:56:01 (GMT)
committerGitHub <noreply@github.com>2025-01-02 18:56:01 (GMT)
commitc9356feef28e6dfc4dc32830d3427a5ae0e426e2 (patch)
tree9e5a2de47a4f7dc03bde2e1300f7ed17ef1c3cba /Lib
parenta626f9a67b76e5fe69677afd5f8317d8c61de8de (diff)
downloadcpython-c9356feef28e6dfc4dc32830d3427a5ae0e426e2.zip
cpython-c9356feef28e6dfc4dc32830d3427a5ae0e426e2.tar.gz
cpython-c9356feef28e6dfc4dc32830d3427a5ae0e426e2.tar.bz2
gh-128400: Stop-the-world when manually calling `faulthandler` (GH-128422)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_faulthandler.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 60815be..fd56dee 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -7,7 +7,7 @@ import signal
import subprocess
import sys
from test import support
-from test.support import os_helper, script_helper, is_android, MS_WINDOWS
+from test.support import os_helper, script_helper, is_android, MS_WINDOWS, threading_helper
import tempfile
import unittest
from textwrap import dedent
@@ -896,6 +896,34 @@ class FaultHandlerTests(unittest.TestCase):
self.assertEqual(output, [])
self.assertEqual(exitcode, 0)
+ @threading_helper.requires_working_threading()
+ @unittest.skipUnless(support.Py_GIL_DISABLED, "only meaningful if the GIL is disabled")
+ def test_free_threaded_dump_traceback(self):
+ # gh-128400: Other threads need to be paused to invoke faulthandler
+ code = dedent("""
+ import faulthandler
+ from threading import Thread, Event
+
+ class Waiter(Thread):
+ def __init__(self):
+ Thread.__init__(self)
+ self.running = Event()
+ self.stop = Event()
+
+ def run(self):
+ self.running.set()
+ self.stop.wait()
+
+ for _ in range(100):
+ waiter = Waiter()
+ waiter.start()
+ waiter.running.wait()
+ faulthandler.dump_traceback(all_threads=True)
+ waiter.stop.set()
+ waiter.join()
+ """)
+ _, exitcode = self.get_output(code)
+ self.assertEqual(exitcode, 0)
if __name__ == "__main__":
unittest.main()