Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 657efca

Browse files
GH-95045: gc untrack _lsprof.Profiler before deallocating it (GH-95315)
Automerge-Triggered-By: GH:pablogsal (cherry picked from commit deacf39) Co-authored-by: Kumar Aditya <[email protected]>
1 parent b77c403 commit 657efca

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix GC crash when deallocating ``_lsprof.Profiler`` by untracking it before calling any callbacks. Patch by Kumar Aditya.

Modules/_lsprof.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ profiler_traverse(ProfilerObject *op, visitproc visit, void *arg)
741741
static void
742742
profiler_dealloc(ProfilerObject *op)
743743
{
744+
PyObject_GC_UnTrack(op);
744745
if (op->flags & POF_ENABLED) {
745746
PyThreadState *tstate = PyThreadState_GET();
746747
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {

0 commit comments

Comments
 (0)