Skip to content

Commit

Permalink
pythongh-116604: Check for gcstate->enabled in _Py_RunGC in free-th…
Browse files Browse the repository at this point in the history
…readed build (python#116663)

This isn't strictly necessary because the implementation of `gc_should_collect`
already checks `gcstate->enabled` in the free-threaded build, but it seems
like a good idea until the common pieces of gc.c and gc_free_threading.c are
refactored out.
  • Loading branch information
colesbury authored and diegorusso committed Apr 17, 2024
1 parent 3505334 commit ea2cdeb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Python/gc_free_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,10 @@ _PyObject_GC_Link(PyObject *op)
void
_Py_RunGC(PyThreadState *tstate)
{
GCState *gcstate = get_gc_state();
if (!gcstate->enabled) {
return;
}
gc_collect_main(tstate, 0, _Py_GC_REASON_HEAP);
}

Expand Down

0 comments on commit ea2cdeb

Please sign in to comment.