Skip to content

Commit bc16730

Browse files
committed
pythongh-129694: Add test_exceptions to parallel TSAN jobs
This would catch the data race involving the MemoryError freelist that was fixed in pythongh-129668.
1 parent 78377c7 commit bc16730

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Diff for: Lib/test/support/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2870,7 +2870,7 @@ def force_not_colorized(func):
28702870
def wrapper(*args, **kwargs):
28712871
with no_color():
28722872
return func(*args, **kwargs)
2873-
return wrapper
2873+
return thread_unsafe(wrapper) # modifying the environment is thread-unsafe
28742874

28752875

28762876
def force_not_colorized_test_class(cls):

Diff for: Lib/test/test_exceptions.py

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def raise_catch(self, exc, excname):
6060
self.assertEqual(buf1, buf2)
6161
self.assertEqual(exc.__name__, excname)
6262

63+
@support.thread_unsafe("TESTFN")
6364
def testRaising(self):
6465
self.raise_catch(AttributeError, "AttributeError")
6566
self.assertRaises(AttributeError, getattr, sys, "undefined_attribute")
@@ -1361,6 +1362,7 @@ def test_unicode_error_str_does_not_crash(self):
13611362
self.assertIsInstance(str(exc), str)
13621363

13631364
@no_tracing
1365+
@support.thread_unsafe("captures stderr")
13641366
def test_badisinstance(self):
13651367
# Bug #2542: if issubclass(e, MyException) raises an exception,
13661368
# it should be ignored
@@ -1484,6 +1486,7 @@ def test_recursion_normalizing_infinite_exception(self):
14841486
self.assertIn(b'Done.', out)
14851487

14861488

1489+
@support.thread_unsafe("uses sys.setrecursionlimit")
14871490
def test_recursion_in_except_handler(self):
14881491

14891492
def set_relative_recursion_limit(n):
@@ -1619,6 +1622,7 @@ class C(object):
16191622

16201623
@cpython_only
16211624
@unittest.skipIf(_testcapi is None, "requires _testcapi")
1625+
@support.thread_unsafe("gc_collect()")
16221626
def test_memory_error_cleanup(self):
16231627
# Issue #5437: preallocated MemoryError instances should not keep
16241628
# traceback objects alive.
@@ -1668,6 +1672,7 @@ def test_errno_ENOTDIR(self):
16681672
os.listdir(__file__)
16691673
self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception)
16701674

1675+
@support.thread_unsafe("uses catch_unraisable_exception")
16711676
def test_unraisable(self):
16721677
# Issue #22836: PyErr_WriteUnraisable() should give sensible reports
16731678
class BrokenDel:
@@ -1687,6 +1692,7 @@ def __del__(self):
16871692
f"deallocator {obj_repr}")
16881693
self.assertIsNotNone(cm.unraisable.exc_traceback)
16891694

1695+
@support.thread_unsafe("captures stderr")
16901696
def test_unhandled(self):
16911697
# Check for sensible reporting of unhandled exceptions
16921698
for exc_type in (ValueError, BrokenStrException):
@@ -1786,6 +1792,7 @@ def g():
17861792
next(i)
17871793

17881794
@unittest.skipUnless(__debug__, "Won't work if __debug__ is False")
1795+
@support.thread_unsafe("modifies global AssertionError")
17891796
def test_assert_shadowing(self):
17901797
# Shadowing AssertionError would cause the assert statement to
17911798
# misbehave.
@@ -1877,6 +1884,7 @@ def test_name_error_has_name(self):
18771884
except NameError as exc:
18781885
self.assertEqual("bluch", exc.name)
18791886

1887+
@support.thread_unsafe("captures stderr")
18801888
def test_issue45826(self):
18811889
# regression test for bpo-45826
18821890
def f():
@@ -1893,6 +1901,7 @@ def f():
18931901

18941902
self.assertIn("aab", err.getvalue())
18951903

1904+
@support.thread_unsafe("captures stderr")
18961905
def test_issue45826_focused(self):
18971906
def f():
18981907
try:
@@ -2295,6 +2304,7 @@ class MySyntaxError(SyntaxError):
22952304
^^^^^
22962305
""", err.getvalue())
22972306

2307+
@support.thread_unsafe("TESTFN")
22982308
def test_encodings(self):
22992309
self.addCleanup(unlink, TESTFN)
23002310
source = (

Diff for: Tools/tsan/suppressions_free_threading.txt

+7
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,12 @@ race_top:PyThreadState_Clear
4444
# Only seen on macOS, sample: https://gist.github.com/aisk/dda53f5d494a4556c35dde1fce03259c
4545
race_top:set_default_allocator_unlocked
4646

47+
# gh-129701: data race during modification of refcount when interning strings
48+
race:intern_common
49+
50+
# gh-128130: race on _PyRuntime.signals.unhandled_keyboard_interrupt
51+
race_top:_PyErr_Display
52+
race_top:run_eval_code_obj
53+
4754
# https://gist.github.com/mpage/6962e8870606cfc960e159b407a0cb40
4855
thread:pthread_create

0 commit comments

Comments
 (0)