8000 gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (#1… · python/cpython@f901f56 · GitHub
[go: up one dir, main page]

Skip to content

Commit f901f56

Browse files
authored
gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (#110657)
Skip test_post_fork_child_no_deadlock() if Python is built with ASAN. Add support.HAVE_ASAN_FORK_BUG.
1 parent 7ca4aaf commit f901f56

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@
7878
msvcrt = None
7979

8080

81-
if support.check_sanitizer(address=True):
81+
if support.HAVE_ASAN_FORK_BUG:
8282
# gh-89363: Skip multiprocessing tests if Python is built with ASAN to
8383
# work around a libasan race condition: dead lock in pthread_create().
84-
raise unittest.SkipTest("libasan has a pthread_create() dead lock")
84+
raise unittest.SkipTest("libasan has a pthread_create() dead lock related to thread+fork")
8585

8686

8787
def latin(s):

Lib/test/support/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
429429
skip = check_sanitizer(address=address, memory=memory, ub=ub)
430430
return unittest.skipIf(skip, reason)
431431

432+
# gh-89363: True if fork() can hang if Python is built with Address Sanitizer
433+
# (ASAN): libasan race condition, dead lock in pthread_create().
434+
HAVE_ASAN_FORK_BUG = check_sanitizer(address=True)
435+
432436

433437
def set_sanitizer_env_var(env, option):
434438
for name in ('ASAN_OPTIONS', 'MSAN_OPTIONS', 'UBSAN_OPTIONS'):

Lib/test/test_logging.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@
7676
pass
7777

7878

79+
# gh-89363: Skip fork() test if Python is built with Address Sanitizer (ASAN)
80+
# to work around a libasan race condition, dead lock in pthread_create().
81+
skip_if_asan_fork = unittest.skipIf(
82+
support.HAVE_ASAN_FORK_BUG,
83+
"libasan has a pthread_create() dead lock related to thread+fork")
84+
85+
7986
class BaseTest(unittest.TestCase):
8087

8188
"""Base class for logging tests."""
@@ -724,6 +731,7 @@ def remove_loop(fname, tries):
724731
# register_at_fork mechanism is also present and used.
725732
@support.requires_fork()
726733
@threading_helper.requires_working_threading()
734+
@skip_if_asan_fork
727735
def test_post_fork_child_no_deadlock(self):
728736
"""Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
729737
class _OurHandler(logging.Handler):

Lib/test/test_threading.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,12 @@
4040
platforms_to_skip = ('netbsd5', 'hp-ux11')
4141

4242

43-
# gh-89363: Skip fork() test if Python is built with Address Sanitizer (ASAN)
44-
# to work around a libasan race condition, dead lock in pthread_create().
45-
skip_if_asan_fork = support.skip_if_sanitizer(
46-
"libasan has a pthread_create() dead lock",
47-
address=True)
48-
49-
5043
def skip_unless_reliable_fork(test):
5144
if not support.has_fork_support:
5245
return unittest.skip("requires working os.fork()")(test)
5346
if sys.platform in platforms_to_skip:
5447 return unittest.skip("due to known OS bug related to thread+fork")(test)
55-
if support.check_sanitizer(address=True):
48+
if support.HAVE_ASAN_FORK_BUG:
5649
return unittest.skip("libasan has a pthread_create() dead lock related to thread+fork")(test)
5750
return test
5851

0 commit comments

Comments
 (0)
0