8000 [3.11] gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657) by miss-islington · Pull Request #110665 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657) #110665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
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
# 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):
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
skip = check_sanitizer(address=address, memory=memory, ub=ub)
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):
"""Skip the test on TLS certificate validation failures."""
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
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):

"""Base class for logging tests."""
Expand Down Expand Up @@ -682,6 +689,7 @@ def remove_loop(fname, tries):
# register_at_fork mechanism is also present and used.
@support.requires_fork()
@threading_helper.requires_working_threading()
@skip_if_asan_fork
def test_post_fork_child_no_deadlock(self):
"""Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
class _OurHandler(logging.Handler):
Expand Down
9 changes: 1 addition & 8 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,12 @@
Py_DEBUG = hasattr(sys, 'gettotalrefcount')


# 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):
if not support.has_fork_support:
return unittest.skip("requires working os.fork()")(test)
if sys.platform in platforms_to_skip:
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 test

Expand Down
0