Skip to content

Commit a81f98b

Browse files
committed
pythongh-112536: Add test_threading to TSAN tests (python#116898)
1 parent 731eef9 commit a81f98b

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Lib/test/libregrtest/tsan.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'test_syslog',
1616
'test_thread',
1717
'test_threadedtempfile',
18+
'test_threading',
1819
'test_threading_local',
1920
'test_threadsignals',
2021
'test_weakref',

Lib/test/support/script_helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class _PythonRunResult(collections.namedtuple("_PythonRunResult",
6464
"""Helper for reporting Python subprocess run results"""
6565
def fail(self, cmd_line):
6666
"""Provide helpful details about failed subcommand runs"""
67-
# Limit to 80 lines to ASCII characters
68-
maxlen = 80 * 100
67+
# Limit to 300 lines of ASCII characters
68+
maxlen = 300 * 100
6969
out, err = self.out, self.err
7070
if len(out) > maxlen:
7171
out = b'(... truncated stdout ...)' + out[-maxlen:]

Lib/test/test_threading.py

+16
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)