mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
[3.12] gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657) (#110664)
gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657)
Skip test_post_fork_child_no_deadlock() if Python is built with ASAN.
Add support.HAVE_ASAN_FORK_BUG.
(cherry picked from commit f901f56313
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
dcd47e506d
commit
55448a5b14
4 changed files with 15 additions and 10 deletions
|
@ -78,10 +78,10 @@ except ImportError:
|
||||||
msvcrt = None
|
msvcrt = None
|
||||||
|
|
||||||
|
|
||||||
if support.check_sanitizer(address=True):
|
if support.HAVE_ASAN_FORK_BUG:
|
||||||
# gh-89363: Skip multiprocessing tests if Python is built with ASAN to
|
# gh-89363: Skip multiprocessing tests if Python is built with ASAN to
|
||||||
# work around a libasan race condition: dead lock in pthread_create().
|
# work around a libasan race condition: dead lock in pthread_create().
|
||||||
raise unittest.SkipTest("libasan has a pthread_create() dead lock")
|
raise unittest.SkipTest("libasan has a pthread_create() dead lock related to thread+fork")
|
||||||
|
|
||||||
|
|
||||||
def latin(s):
|
def latin(s):
|
||||||
|
|
|
@ -428,6 +428,10 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
|
||||||
skip = check_sanitizer(address=address, memory=memory, ub=ub)
|
skip = check_sanitizer(address=address, memory=memory, ub=ub)
|
||||||
return unittest.skipIf(skip, reason)
|
return unittest.skipIf(skip, reason)
|
||||||
|
|
||||||
|
# gh-89363: True if fork() can hang if Python is built with Address Sanitizer
|
||||||
|
# (ASAN): libasan race condition, dead lock in pthread_create().
|
||||||
|
HAVE_ASAN_FORK_BUG = check_sanitizer(address=True)
|
||||||
|
|
||||||
|
|
||||||
def system_must_validate_cert(f):
|
def system_must_validate_cert(f):
|
||||||
"""Skip the test on TLS certificate validation failures."""
|
"""Skip the test on TLS certificate validation failures."""
|
||||||
|
|
|
@ -76,6 +76,13 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# gh-89363: Skip fork() test if Python is built with Address Sanitizer (ASAN)
|
||||||
|
# to work around a libasan race condition, dead lock in pthread_create().
|
||||||
|
skip_if_asan_fork = unittest.skipIf(
|
||||||
|
support.HAVE_ASAN_FORK_BUG,
|
||||||
|
"libasan has a pthread_create() dead lock related to thread+fork")
|
||||||
|
|
||||||
|
|
||||||
class BaseTest(unittest.TestCase):
|
class BaseTest(unittest.TestCase):
|
||||||
|
|
||||||
"""Base class for logging tests."""
|
"""Base class for logging tests."""
|
||||||
|
@ -730,6 +737,7 @@ class HandlerTest(BaseTest):
|
||||||
# register_at_fork mechanism is also present and used.
|
# register_at_fork mechanism is also present and used.
|
||||||
@support.requires_fork()
|
@support.requires_fork()
|
||||||
@threading_helper.requires_working_threading()
|
@threading_helper.requires_working_threading()
|
||||||
|
@skip_if_asan_fork
|
||||||
def test_post_fork_child_no_deadlock(self):
|
def test_post_fork_child_no_deadlock(self):
|
||||||
"""Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
|
"""Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
|
||||||
class _OurHandler(logging.Handler):
|
class _OurHandler(logging.Handler):
|
||||||
|
|
|
@ -35,19 +35,12 @@ threading_helper.requires_working_threading(module=True)
|
||||||
platforms_to_skip = ('netbsd5', 'hp-ux11')
|
platforms_to_skip = ('netbsd5', 'hp-ux11')
|
||||||
|
|
||||||
|
|
||||||
# gh-89363: Skip fork() test if Python is built with Address Sanitizer (ASAN)
|
|
||||||
# to work around a libasan race condition, dead lock in pthread_create().
|
|
||||||
skip_if_asan_fork = support.skip_if_sanitizer(
|
|
||||||
"libasan has a pthread_create() dead lock",
|
|
||||||
address=True)
|
|
||||||
|
|
||||||
|
|
||||||
def skip_unless_reliable_fork(test):
|
def skip_unless_reliable_fork(test):
|
||||||
if not support.has_fork_support:
|
if not support.has_fork_support:
|
||||||
return unittest.skip("requires working os.fork()")(test)
|
return unittest.skip("requires working os.fork()")(test)
|
||||||
if sys.platform in platforms_to_skip:
|
if sys.platform in platforms_to_skip:
|
||||||
return unittest.skip("due to known OS bug related to thread+fork")(test)
|
return unittest.skip("due to known OS bug related to thread+fork")(test)
|
||||||
if support.check_sanitizer(address=True):
|
if support.HAVE_ASAN_FORK_BUG:
|
||||||
return unittest.skip("libasan has a pthread_create() dead lock related to thread+fork")(test)
|
return unittest.skip("libasan has a pthread_create() dead lock related to thread+fork")(test)
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue