aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/gc_free_threading.c
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-03-07 08:29:39 +0900
committerGitHub <noreply@github.com>2024-03-07 08:29:39 +0900
commit2d4955fcf2a54d7ffc06a48774863ff65ba250d2 (patch)
tree872dcfda0e2b7dedbe720fc70f3c12caa7a03ca2 /Python/gc_free_threading.c
parent68b8ffff8c4b20d2f46b708b1a7906377ecc255f (diff)
downloadcpython-2d4955fcf2a54d7ffc06a48774863ff65ba250d2.tar.gz
cpython-2d4955fcf2a54d7ffc06a48774863ff65ba250d2.zip
gh-116397: Move the _PyGC_ClearAllFreeLists to the safe point (gh-116414)
Diffstat (limited to 'Python/gc_free_threading.c')
-rw-r--r--Python/gc_free_threading.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index 18893c6c391..c7883cd3864 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -1058,6 +1058,8 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state)
// Handle any objects that may have resurrected after the finalization.
_PyEval_StopTheWorld(interp);
err = handle_resurrected_objects(state);
+ // Clear free lists in all threads
+ _PyGC_ClearAllFreeLists(interp);
_PyEval_StartTheWorld(interp);
if (err < 0) {
@@ -1160,8 +1162,9 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
n+m, n, d);
}
- // Clear free lists in all threads
- _PyGC_ClearAllFreeLists(interp);
+ // Clear the current thread's free-list again.
+ _PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
+ _PyObject_ClearFreeLists(&tstate_impl->freelists, 0);
if (_PyErr_Occurred(tstate)) {
if (reason == _Py_GC_REASON_SHUTDOWN) {