]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] gh-128679: Fix tracemalloc.stop() race conditions (#128897) (#129022)
authorVictor Stinner <vstinner@python.org>
Sun, 19 Jan 2025 13:24:14 +0000 (14:24 +0100)
committerGitHub <noreply@github.com>
Sun, 19 Jan 2025 13:24:14 +0000 (13:24 +0000)
commit6df22cbf6049d09f45e214e74345a5159f7e202b
treecdcdb375bf0c6db4050b4c85b5cd2e80a07ee5f5
parent83de72e5ec9522a1b01d8259f574efa0d6128d6a
[3.12] gh-128679: Fix tracemalloc.stop() race conditions (#128897) (#129022)

[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.

(cherry picked from commit 6b47499510e47c0401d1f6cca2660fc12c496e39)
Include/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