Skip to content

Commit 0fd77ae

Browse files
fix garbage collection of profiler
1 parent 78eb3f7 commit 0fd77ae

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
@@ -747,6 +747,7 @@ profiler_traverse(ProfilerObject *op, visitproc visit, void *arg)
747747
static void
748748
profiler_dealloc(ProfilerObject *op)
749749
{
750+
PyObject_GC_UnTrack(op);
750751
if (op->flags & POF_ENABLED) {
751752
PyThreadState *tstate = _PyThreadState_GET();
752753
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {

0 commit comments

Comments
 (0)