From: Victor Stinner Date: Sat, 18 Jan 2025 15:13:54 +0000 (+0100) Subject: gh-128679: Skip test_tracemalloc_track_race() on debug build (#128988) X-Git-Tag: v3.14.0a5~380 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9bc19643ed54b2aa8558e87fd3a04e8bd1ea7fb2;p=thirdparty%2FPython%2Fcpython.git gh-128679: Skip test_tracemalloc_track_race() on debug build (#128988) 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. --- diff --git a/Lib/test/test_tracemalloc.py b/Lib/test/test_tracemalloc.py index da2db2877557..a848363fcd1d 100644 --- a/Lib/test/test_tracemalloc.py +++ b/Lib/test/test_tracemalloc.py @@ -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()