]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128679: Skip test_tracemalloc_track_race() on debug build (#128988)
authorVictor Stinner <vstinner@python.org>
Sat, 18 Jan 2025 15:13:54 +0000 (16:13 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Jan 2025 15:13:54 +0000 (15:13 +0000)
There is a race condition between PyMem_SetAllocator() and
PyMem_RawMalloc()/PyMem_RawFree(). While PyMem_SetAllocator() write
is protected by a lock, PyMem_RawMalloc()/PyMem_RawFree() reads are
not protected by a lock. PyMem_RawMalloc()/PyMem_RawFree() can be
called with an old context and the new function pointer.

On a release build, it's not an issue since the context is not used.
On a debug build, the debug hooks use the context and so can crash.

Lib/test/test_tracemalloc.py

index da2db28775578a27b4200df78422907d6642dc0a..a848363fcd1de9e3f69445cbcdb513237f36a014 100644 (file)
@@ -1103,6 +1103,8 @@ class TestCAPI(unittest.TestCase):
 
     @unittest.skipIf(_testcapi is None, 'need _testcapi')
     @threading_helper.requires_working_threading()
+    # gh-128679: Test crash on a debug build (especially on FreeBSD).
+    @unittest.skipIf(support.Py_DEBUG, 'need release build')
     def test_tracemalloc_track_race(self):
         # gh-128679: Test fix for tracemalloc.stop() race condition
         _testcapi.tracemalloc_track_race()