Skip to content

Commit

Permalink
GH-95045: gc untrack _lsprof.Profiler before deallocating it (GH-95315)
Browse files Browse the repository at this point in the history
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit deacf39)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
miss-islington and kumaraditya303 authored Jul 27, 2022
1 parent b77c403 commit 657efca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix GC crash when deallocating ``_lsprof.Profiler`` by untracking it before calling any callbacks. Patch by Kumar Aditya.
1 change: 1 addition & 0 deletions Modules/_lsprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ profiler_traverse(ProfilerObject *op, visitproc visit, void *arg)
static void
profiler_dealloc(ProfilerObject *op)
{
PyObject_GC_UnTrack(op);
if (op->flags & POF_ENABLED) {
PyThreadState *tstate = PyThreadState_GET();
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {
Expand Down

0 comments on commit 657efca

Please sign in to comment.