]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 11 Oct 2023 01:22:51 +0000 (03:22 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Oct 2023 01:22:51 +0000 (01:22 +0000)
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 f901f56313610389027cb4eae80d1d4b071aef69)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/_test_multiprocessing.py
Lib/test/support/__init__.py
Lib/test/test_logging.py
Lib/test/test_threading.py

index 42441fed79bf3ea44ae06dd83bc429850132db88..834bc6b87fb8d29e1b1d8f21eeb34b04186dbc92 100644 (file)
@@ -77,10 +77,10 @@ except ImportError:
     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):
index 1d3b0053bf86c9d70454e5fb512d67b975ae7b67..f5307b6442bf66b6442b71ea6c09644e9a489d47 100644 (file)
@@ -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."""
index ccf479d8e7e1c2551f343a231a7385d66f1ce196..e097acd85eb72ba7a170a8a721d226d5126fc2b4 100644 (file)
@@ -76,6 +76,13 @@ except ImportError:
     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."""
@@ -682,6 +689,7 @@ class HandlerTest(BaseTest):
     # 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):
index a4192acd6dbc5c3ceb588cacace74d70b95a008c..17319c366a483bea64c6c9094f55d2a7f26dd70f 100644 (file)
@@ -37,19 +37,12 @@ platforms_to_skip = ('netbsd5', 'hp-ux11')
 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