diff options
author | Sam Gross <colesbury@gmail.com> | 2024-03-12 17:12:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-12 17:12:02 (GMT) |
commit | 5d72b753889977fa6d2d015499de03f94e16b035 (patch) | |
tree | 9bd1481bf1ff75573db69f78c8d85e8989eb351d | |
parent | df4784b3b7519d137ca6a1aeb500ef59e24a7f9b (diff) | |
download | cpython-5d72b753889977fa6d2d015499de03f94e16b035.zip cpython-5d72b753889977fa6d2d015499de03f94e16b035.tar.gz cpython-5d72b753889977fa6d2d015499de03f94e16b035.tar.bz2 |
gh-116604: Check for `gcstate->enabled` in _Py_RunGC in free-threaded build (#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.
-rw-r--r-- | Python/gc_free_threading.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c index 59e7601..2b13d1f 100644 --- a/Python/gc_free_threading.c +++ b/Python/gc_free_threading.c @@ -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); } |