@@ -47,14 +47,11 @@ def skip_unless_reliable_fork(test):
47
47
return unittest .skip ("due to known OS bug related to thread+fork" )(test )
48
48
if support .HAVE_ASAN_FORK_BUG :
49
49
return unittest .skip ("libasan has a pthread_create() dead lock related to thread+fork" )(test )
50
+ if support .check_sanitizer (thread = True ):
51
+ return unittest .skip ("TSAN doesn't support threads after fork" )
50
52
return test
51
53
52
54
53
- skip_if_tsan_fork = unittest .skipIf (
54
- support .check_sanitizer (thread = True ),
55
- "TSAN doesn't support threads after fork" )
56
-
57
-
58
55
def requires_subinterpreters (meth ):
59
56
"""Decorator to skip a test if subinterpreters are not supported."""
60
57
return unittest .skipIf (interpreters is None ,
@@ -428,6 +425,10 @@ def test_finalize_running_thread(self):
428
425
# Issue 1402: the PyGILState_Ensure / _Release functions may be called
429
426
# very late on python exit: on deallocation of a running thread for
430
427
# example.
428
+ if support .check_sanitizer (thread = True ):
429
+ # the thread running `time.sleep(100)` below will still be alive
430
+ # at process exit
431
+ self .skipTest ("TSAN would report thread leak" )
431
432
import_module ("ctypes" )
432
433
433
434
rc , out , err = assert_python_failure ("-c" , """if 1:
@@ -460,6 +461,11 @@ def waitingThread():
460
461
def test_finalize_with_trace (self ):
461
462
# Issue1733757
462
463
# Avoid a deadlock when sys.settrace steps into threading._shutdown
464
+ if support .check_sanitizer (thread = True ):
465
+ # the thread running `time.sleep(2)` below will still be alive
466
+ # at process exit
467
+ self .skipTest ("TSAN would report thread leak" )
468
+
463
469
assert_python_ok ("-c" , """if 1:
464
470
import sys, threading
465
471
@@ -639,7 +645,6 @@ def test_daemon_param(self):
639
645
self .assertTrue (t .daemon )
640
646
641
647
@skip_unless_reliable_fork
642
- @skip_if_tsan_fork
643
648
def test_dummy_thread_after_fork (self ):
644
649
# Issue #14308: a dummy thread in the active list doesn't mess up
645
650
# the after-fork mechanism.
@@ -709,7 +714,6 @@ def f():
709
714
710
715
@skip_unless_reliable_fork
711
716
@unittest .skipUnless (hasattr (os , 'waitpid' ), "test needs os.waitpid()" )
712
- @skip_if_tsan_fork
713
717
def test_main_thread_after_fork (self ):
714
718
code = """if 1:
715
719
import os, threading
@@ -1278,7 +1282,6 @@ def test_2_join_in_forked_process(self):
1278
1282
self ._run_and_join (script )
1279
1283
1280
1284
@skip_unless_reliable_fork
1281
- @skip_if_tsan_fork
1282
1285
def test_3_join_in_forked_from_thread (self ):
1283
1286
# Like the test above, but fork() was called from a worker thread
1284
1287
# In the forked process, the main Thread object must be marked as stopped.
@@ -1311,6 +1314,11 @@ def test_4_daemon_threads(self):
1311
1314
# Check that a daemon thread cannot crash the interpreter on shutdown
1312
1315
# by manipulating internal structures that are being disposed of in
1313
1316
# the main thread.
1317
+ if support .check_sanitizer (thread = True ):
1318
+ # some of the threads running `random_io` below will still be alive
1319
+ # at process exit
1320
+ self .skipTest ("TSAN would report thread leak" )
1321
+
1314
1322
script = """if True:
1315
1323
import os
1316
1324
import random
0 commit comments