mirror of
https://github.com/python/cpython.git
synced 2025-11-11 11:01:39 +00:00
gh-128679: Redesign tracemalloc locking (#128888)
* Use TABLES_LOCK() to protect 'tracemalloc_config.tracing'. * Hold TABLES_LOCK() longer while accessing tables. * tracemalloc_realloc() and tracemalloc_free() no longer remove the trace on reentrant call. * _PyTraceMalloc_Stop() unregisters _PyTraceMalloc_TraceRef(). * _PyTraceMalloc_GetTraces() sets the reentrant flag. * tracemalloc_clear_traces_unlocked() sets the reentrant flag.
This commit is contained in:
parent
080f444a58
commit
36c5e3bcc2
5 changed files with 302 additions and 364 deletions
|
|
@ -215,18 +215,14 @@ static struct PyModuleDef module_def = {
|
|||
PyMODINIT_FUNC
|
||||
PyInit__tracemalloc(void)
|
||||
{
|
||||
PyObject *m;
|
||||
m = PyModule_Create(&module_def);
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
#ifdef Py_GIL_DISABLED
|
||||
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
||||
#endif
|
||||
|
||||
if (_PyTraceMalloc_Init() < 0) {
|
||||
Py_DECREF(m);
|
||||
PyObject *mod = PyModule_Create(&module_def);
|
||||
if (mod == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m;
|
||||
#ifdef Py_GIL_DISABLED
|
||||
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
|
||||
#endif
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue