From f4442f7580aafc41cca6d13d500018dd830f275c Mon Sep 17 00:00:00 2001 From: nekevss Date: Thu, 1 Dec 2022 21:44:23 -0500 Subject: [PATCH] Fix to weak_trace for gc ref cycles --- boa_gc/src/internals/gc_box.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/boa_gc/src/internals/gc_box.rs b/boa_gc/src/internals/gc_box.rs index 9c5ac998d9b..8ce48182ecf 100644 --- a/boa_gc/src/internals/gc_box.rs +++ b/boa_gc/src/internals/gc_box.rs @@ -157,13 +157,16 @@ impl GcBox { } } - /// Trace inner data + /// Trace inner data and search for ephemerons to add to the ephemeron queue. #[inline] pub(crate) fn weak_trace_inner(&self) { - // SAFETY: if a `GcBox` has `weak_trace_inner` called, then the inner. - // value must have been deemed as reachable. - unsafe { - self.value.weak_trace(); + if !self.header.is_marked() && !self.header.is_ephemeron() { + self.header.mark(); + // SAFETY: if a `GcBox` has `weak_trace_inner` called, then the inner. + // value must have been deemed as reachable. + unsafe { + self.value.weak_trace(); + } } }