Skip to content

Commit 35ee888

Browse files
committed
Fix double-set of gc_finalized preventing __del__ from being called
gc_state set gc_finalized before calling try_call_finalizer, but try_call_finalizer internally checks gc_finalized and skips __del__ if already set. Remove the redundant set_gc_finalized call.
1 parent 8b7ddd2 commit 35ee888

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/vm/src/gc_state.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,11 @@ impl GcState {
542542
}
543543
}
544544

545-
// 6d: Call __del__ on unreachable objects (skip already-finalized)
545+
// 6d: Call __del__ on unreachable objects (skip already-finalized).
546+
// try_call_finalizer() internally checks gc_finalized() and sets it,
547+
// so we must NOT set it beforehand.
546548
for obj_ref in &unreachable_refs {
547-
let obj = obj_ref.as_ref();
548-
if !obj.gc_finalized() {
549-
obj.set_gc_finalized();
550-
obj_ref.try_call_finalizer();
551-
}
549+
obj_ref.try_call_finalizer();
552550
}
553551

554552
// Detect resurrection

0 commit comments

Comments
 (0)