From 8da46a9d21dd154cf4509b74fae39fa7c51d478c Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 2 Dec 2022 16:28:54 +0000 Subject: [PATCH] Fix to weak_trace for `boa_tester` (#2470) This Pull Request fixes the current issue with the `boa_gc` when running `boa_tester` in parallel on Ubuntu. It looks like since we are running the `gc` in parallel something may not being cleaned up correctly that creates a reference cycle. The below changes should account for that. It changes the following: - Updates `weak_trace` to account for `Gc` reference 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 9c5ac998d9..8ce48182ec 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(); + } } }