mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
[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.
This commit is contained in:
parent
ef9961840b
commit
6b47499510
7 changed files with 250 additions and 117 deletions
|
@ -706,6 +706,11 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
|
|||
return _PyStatus_NO_MEMORY();
|
||||
}
|
||||
|
||||
status = _PyTraceMalloc_Init();
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
PyThreadState *tstate = _PyThreadState_New(interp,
|
||||
_PyThreadState_WHENCE_INIT);
|
||||
if (tstate == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue