8000 gh-116397: Move the _PyGC_ClearAllFreeLists to the safe point · corona10/cpython@9ec369f · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ec369f

Browse files
committed
pythongh-116397: Move the _PyGC_ClearAllFreeLists to the safe point
1 parent 33c0aa3 commit 9ec369f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Lib/test/test_sys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def test_getallocatedblocks(self):
10461046
self.assertLessEqual(b, a)
10471047
gc.collect()
10481048
c = sys.getallocatedblocks()
1049-
self.assertIn(c, range(b - 50, b + 50))
1049+
self.assertLessEqual(c, b)
10501050

10511051
def test_is_finalizing(self):
10521052
self.assertIs(sys.is_finalizing(), False)

Python/gc_free_threading.c

Lines changed: 2 additions & 3 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,9 +1162,6 @@ 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-
11661165
if (_PyErr_Occurred(tstate)) {
11671166
if (reason == _Py_GC_REASON_SHUTDOWN) {
11681167
_PyErr_Clear(tstate);

0 commit comments

Comments
 (0)
0