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.
(cherry picked from commit 6b47499510
)
This commit is contained in:
parent
83de72e5ec
commit
6df22cbf60
7 changed files with 250 additions and 116 deletions
|
@ -654,6 +654,11 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
|
|||
// didn't depend on interp->feature_flags being set already.
|
||||
_PyObject_InitState(interp);
|
||||
|
||||
status = _PyTraceMalloc_Init();
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
PyThreadState *tstate = _PyThreadState_New(interp);
|
||||
if (tstate == NULL) {
|
||||
return _PyStatus_ERR("can't make first thread");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue