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

Skip to content

Commit 5d72b75

Browse files
authored
pythongh-116604: Check for gcstate->enabled in _Py_RunGC in free-threaded 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.
1 parent df4784b commit 5d72b75

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Python/gc_free_threading.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,10 @@ _PyObject_GC_Link(PyObject *op)
16031603
void
16041604
_Py_RunGC(PyThreadState *tstate)
16051605
{
1606+
GCState *gcstate = get_gc_state();
1607+
if (!gcstate->enabled) {
1608+
return;
1609+
}
16061610
gc_collect_main(tstate, 0, _Py_GC_REASON_HEAP);
16071611
}
16081612

0 commit comments

Comments
 (0)