mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191)
Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack()
during late Python finalization.
* Call _PyTraceMalloc_Fini() later in Python finalization.
* Test also PyTraceMalloc_Untrack() without the GIL
* PyTraceMalloc_Untrack() now gets the GIL.
* Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race().
(cherry picked from commit 46c7e13c05
)
This commit is contained in:
parent
d674792ba7
commit
e3b3e01d6a
5 changed files with 78 additions and 14 deletions
|
@ -2156,7 +2156,7 @@ _Py_Finalize(_PyRuntimeState *runtime)
|
|||
|
||||
/* Disable tracemalloc after all Python objects have been destroyed,
|
||||
so it is possible to use tracemalloc in objects destructor. */
|
||||
_PyTraceMalloc_Fini();
|
||||
_PyTraceMalloc_Stop();
|
||||
|
||||
/* Finalize any remaining import state */
|
||||
// XXX Move these up to where finalize_modules() is currently.
|
||||
|
@ -2209,6 +2209,8 @@ _Py_Finalize(_PyRuntimeState *runtime)
|
|||
|
||||
finalize_interp_clear(tstate);
|
||||
|
||||
_PyTraceMalloc_Fini();
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* Display addresses (& refcnts) of all objects still alive.
|
||||
* An address can be used to find the repr of the object, printed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue