Skip to content

Commit 45f639d

Browse files
committed
Avoid second debug print check
1 parent e0a37d6 commit 45f639d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎Python/gc_free_threading.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,18 +2158,19 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state,
21582158
// Deallocations after the refcount merge may run Python code.
21592159
bool needs_resurrection_check = state->objs_to_decref.head != 0;
21602160

2161-
// Force resurrection code path which will run the debug print
2161+
bool debug_print = false;
21622162
if (FT_ATOMIC_LOAD_INT_RELAXED(interp->gc.debug) & _PyGC_DEBUG_COLLECTABLE) {
2163-
needs_resurrection_check = true;
2163+
// Trigger debug print once we have exited start the world in re
2164+
debug_print = true;
21642165
}
21652166

21662167
// Find weakref callbacks and pending finalizers (but do not call them).
21672168
bool has_finalizers = prepare_finalization(state, &needs_resurrection_check);
2168-
if (needs_resurrection_check) {
2169+
if (needs_resurrection_check || debug_print) {
21692170
_PyEval_StartTheWorld(interp);
21702171

21712172
// Print debugging information.
2172-
if (FT_ATOMIC_LOAD_INT_RELAXED(interp->gc.debug) & _PyGC_DEBUG_COLLECTABLE) {
2173+
if (debug_print) {
21732174
PyObject *op;
21742175
WORKSTACK_FOR_EACH(&state->unreachable, op) {
21752176
debug_cycle("collectable", op);

0 commit comments

Comments
 (0)