@@ -47,6 +47,8 @@ def skip_unless_reliable_fork(test):
4747 return unittest .skip ("due to known OS bug related to thread+fork" )(test )
4848 if support .HAVE_ASAN_FORK_BUG :
4949 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" )
5052 return test
5153
5254
@@ -384,6 +386,10 @@ def test_finalize_running_thread(self):
384386 # Issue 1402: the PyGILState_Ensure / _Release functions may be called
385387 # very late on python exit: on deallocation of a running thread for
386388 # example.
389+ if support .check_sanitizer (thread = True ):
390+ # the thread running `time.sleep(100)` below will still be alive
391+ # at process exit
392+ self .skipTest ("TSAN would report thread leak" )
387393 import_module ("ctypes" )
388394
389395 rc , out , err = assert_python_failure ("-c" , """if 1:
@@ -416,6 +422,11 @@ def waitingThread():
416422 def test_finalize_with_trace (self ):
417423 # Issue1733757
418424 # Avoid a deadlock when sys.settrace steps into threading._shutdown
425+ if support .check_sanitizer (thread = True ):
426+ # the thread running `time.sleep(2)` below will still be alive
427+ # at process exit
428+ self .skipTest ("TSAN would report thread leak" )
429+
419430 assert_python_ok ("-c" , """if 1:
420431 import sys, threading
421432
@@ -1223,6 +1234,11 @@ def test_4_daemon_threads(self):
12231234 # Check that a daemon thread cannot crash the interpreter on shutdown
12241235 # by manipulating internal structures that are being disposed of in
12251236 # the main thread.
1237+ if support .check_sanitizer (thread = True ):
1238+ # some of the threads running `random_io` below will still be alive
1239+ # at process exit
1240+ self .skipTest ("TSAN would report thread leak" )
1241+
12261242 script = """if True:
12271243 import os
12281244 import random
0 commit comments