8000 gh-116397: Move the _PyGC_ClearAllFreeLists to the safe point (gh-116… · python/cpython@2d4955f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d4955f

Browse files
authored
gh-116397: Move the _PyGC_ClearAllFreeLists to the safe point (gh-116414)
1 parent 68b8fff commit 2d4955f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Python/gc_free_threading.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,8 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state)
10581058
// Handle any objects that may have resurrected after the finalization.
10591059
_PyEval_StopTheWorld(interp);
10601060
err = handle_resurrected_objects(state);
1061+
// Clear free lists in all threads
1062+
_PyGC_ClearAllFreeLists(interp);
10611063
_PyEval_StartTheWorld(interp);
10621064

10631065
if (err < 0) {
@@ -1160,8 +1162,9 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
11601162
n+m, n, d);
11611163
}
11621164

1163-
// Clear free lists in all threads
1164-
_PyGC_ClearAllFreeLists(interp);
1165+
// Clear the current thread's free-list again.
1166+
_PyThreadStateImpl *tstate_impl = (_PyThreadStateImpl *)tstate;
1167+
_PyObject_ClearFreeLists(&tstate_impl->freelists, 0);
11651168

11661169
if (_PyErr_Occurred(tstate)) {
11671170
if (reason == _Py_GC_REASON_SHUTDOWN) {

0 commit comments

Comments
 (0)
0