]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897)
authorVictor Stinner <vstinner@python.org>
Sat, 18 Jan 2025 23:39:07 +0000 (00:39 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Jan 2025 23:39:07 +0000 (23:39 +0000)
commit6b47499510e47c0401d1f6cca2660fc12c496e39
tree2645a4eeb72c2f9b982596f628166bf6b89e5ef0
parentef9961840b546aba33b168fd8f5788e1ea1960e8
[3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897)

tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(),
PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check
tracemalloc_config.tracing after calling TABLES_LOCK().

_PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(),
especially setting tracemalloc_config.tracing to 1.

Add a test using PyTraceMalloc_Track() to test tracemalloc.stop()
race condition.

Call _PyTraceMalloc_Init() at Python startup.
Include/internal/pycore_tracemalloc.h
Lib/test/test_tracemalloc.py
Misc/NEWS.d/next/Library/2025-01-10-15-43-52.gh-issue-128679.KcfVVR.rst [new file with mode: 0644]
Modules/_testcapimodule.c
Modules/_tracemalloc.c
Python/pylifecycle.c
Python/tracemalloc.c