diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index b675cf4ba2cc..8dc3539df4c3 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -3504,6 +3504,10 @@ struct AssertNonGrayTracer final : public JS::CallbackTracer { void onChild(const JS::GCCellPtr& thing) override { MOZ_ASSERT(!thing.asCell()->isMarkedGray()); } + // This is used by the UnmarkGray tracer only, and needs to report itself + // as the non-gray tracer to not trigger assertions. Do not use it in another + // context without making this more generic. + TracerKind getTracerKind() const override { return TracerKind::UnmarkGray; } }; #endif diff --git a/js/src/jit-test/tests/gc/bug-1557928.js b/js/src/jit-test/tests/gc/bug-1557928.js new file mode 100644 index 000000000000..560df858e99a --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-1557928.js @@ -0,0 +1,16 @@ +var g = newGlobal({ newCompartment: true }); +var dbg = new Debugger; +var gw = dbg.addDebuggee(g); +lfOffThreadGlobal = g; +lfOffThreadGlobal.offThreadCompileScript(` + grayRoot()[0] = "foo"; + `); +lfOffThreadGlobal.runOffThreadScript(); +var g = newGlobal({newCompartment: true}); +var gw = dbg.addDebuggee(g); +lfOffThreadGlobal = null; +gc(); +schedulegc(this); +schedulegc('atoms'); +gc('zone'); +