Closed Bug 2001969 Opened 1 year ago Closed 1 year ago

Assertion failure: !js::gc::EdgeNeedsSweepUnbarrieredSlow(&obj), at js/HeapAPI.h:962 with Debugger

Categories

(Core :: JavaScript Engine, defect, P1)

x86_64
Linux
defect

Tracking

()

VERIFIED FIXED
147 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox145 --- unaffected
firefox146 --- unaffected
firefox147 + verified

People

(Reporter: decoder, Assigned: jonco)

References

(Blocks 1 open bug, Regression)

Details

(4 keywords, Whiteboard: [bugmon:update,bisected,confirmed][fuzzblocker])

Attachments

(2 files, 1 external file)

The following testcase crashes on mozilla-central revision 20251124-7f41ffc04dd6 (debug build, run with --fuzzing-safe --ion-offthread-compile=off --baseline-warmup-threshold=0):

gczeal(2, 4)
function assertOffsetColumns(code) {
  const global = newGlobal({newCompartment: true});
  const lines = code.split(/\r?\n|\r]/g);
  const execCode = lines[lines.length - 1];
  global.eval(execCode);
  const dbg = new Debugger;
  let debuggeeFn = dbg.addDebuggee(global).makeDebuggeeValue(global.f);
  const { script } = debuggeeFn;
  for (const offset of script.getAllColumnOffsets()) {
    script.setBreakpoint(offset.offset, {});
  }
  global.f(3);
  throw new Error(`Assertion failed: ${foo}`);
}
assertOffsetColumns("function f(){}")

Backtrace:

received signal SIGSEGV, Segmentation fault.
#0  0x000055555772addd in JS::ExposeObjectToActiveJS(JSObject*) ()
#1  0x00005555577185ba in js::WeakMap<js::AbstractGeneratorObject*, js::DebuggerFrame*, js::TrackedAllocPolicy<(js::TrackingKind)1> >::lookup(js::AbstractGeneratorObject* const&) const ()
#2  0x000055555770fb63 in js::DebugScript::get(JSScript*) ()
#3  0x0000555557711cd9 in js::DebugAPI::stepModeEnabledSlow(JSScript*) ()
#4  0x0000555557e254e0 in js::jit::BaselineScript::toggleDebugTraps(JSScript*, unsigned char*) ()
#5  0x00005555577341ed in js::Debugger::removeDebuggeeGlobal(JS::GCContext*, js::GlobalObject*, mozilla::detail::HashTable<js::WeakHeapPtr<js::GlobalObject*> const, mozilla::HashSet<js::WeakHeapPtr<js::GlobalObject*>, js::StableCellHasher<js::WeakHeapPtr<js::GlobalObject*> >, js::TrackedAllocPolicy<(js::TrackingKind)1> >::SetHashPolicy, js::TrackedAllocPolicy<(js::TrackingKind)1> >::Enum*, js::Debugger::FromSweep) ()
#6  0x000055555773366d in js::DebugAPI::sweepAll(JS::GCContext*) ()
#7  0x0000555557a4e3e0 in js::gc::GCRuntime::sweepDebuggerOnMainThread(JS::GCContext*) ()
#8  0x0000555557a4f5e9 in js::gc::GCRuntime::beginSweepingSweepGroup(JS::GCContext*, JS::SliceBudget&) ()
#9  0x0000555557a87b6c in sweepaction::SweepActionSequence::run(js::gc::SweepAction::Args&) ()
#10 0x0000555557a74a79 in sweepaction::SweepActionForEach<js::gc::SweepGroupsIter, JSRuntime*>::run(js::gc::SweepAction::Args&) ()
#11 0x0000555557a58629 in js::gc::GCRuntime::performSweepActions(JS::SliceBudget&) ()
#12 0x00005555579c3a66 in js::gc::GCRuntime::incrementalSlice(JS::SliceBudget&, JS::GCReason, bool) ()
#13 0x00005555579c7a63 in js::gc::GCRuntime::gcCycle(bool, JS::SliceBudget const&, JS::GCReason) ()
#14 0x00005555579c93cb in js::gc::GCRuntime::collect(bool, JS::SliceBudget const&, JS::GCReason) ()
#15 0x00005555579aec07 in js::gc::GCRuntime::gc(JS::GCOptions, JS::GCReason) ()
#16 0x00005555579cd954 in js::gc::GCRuntime::runDebugGC() ()
#17 0x000055555708ab3b in void* js::gc::CellAllocator::AllocNurseryOrTenuredCell<(JS::TraceKind)2, (js::AllowGC)1>(JSContext*, js::gc::AllocKind, unsigned long, js::gc::Heap, js::gc::AllocSite*) ()
#18 0x00005555571a14d3 in JSLinearString* JSLinearString::newValidLength<(js::AllowGC)1, unsigned char>(JSContext*, JS::MutableHandle<JSString::OwnedChars<unsigned char> >, js::gc::Heap) ()
#19 0x000055555744ea7f in JSLinearString* js::NewStringCopyNDontDeflateNonStaticValidLength<(js::AllowGC)1, unsigned char>(JSContext*, unsigned char const*, unsigned long, js::gc::Heap) ()
#20 0x00005555576af825 in FormatErrorMessage(JSContext*, JS::Handle<JSString*>, JS::Handle<JSString*>) ()
#21 0x00005555576ae0c1 in JS::ErrorReportBuilder::init(JSContext*, JS::ExceptionStack const&, JS::ErrorReportBuilder::SniffingBehavior) ()
#22 0x0000555556ed5427 in auto js::shell::AutoReportException::~AutoReportException()::$_0::operator()<JS::ErrorReportBuilder, JS::ExceptionStack>(JSContext*, JS::ErrorReportBuilder&, JS::ExceptionStack const&, char const*) const ()
#23 0x0000555556ed4d4a in js::shell::AutoReportException::~AutoReportException() ()
#24 0x0000555556edfe6c in Shell(JSContext*, js::cli::OptionParser*) ()
#25 0x0000555556ed6c08 in main ()
rax	0x0	0
rbx	0x7fffffffc590	140737488340368
rcx	0x3c2	962
rdx	0x7ffff7804563	140737345766755
rsi	0x0	0
rdi	0x7ffff7805700	140737345771264
rbp	0x7fffffffc540	140737488340288
rsp	0x7fffffffc520	140737488340256
r8	0x0	0
r9	0x3	3
r10	0x2	2
r11	0x293	659
r12	0x7fffb620e6f1	140736248997617
r13	0x0	0
r14	0x7fffb629f618	140736249591320
r15	0x7fffb629f5e0	140736249591264
rip	0x55555772addd <JS::ExposeObjectToActiveJS(JSObject*)+205>
=> 0x55555772addd <_ZN2JSL22ExposeObjectToActiveJSEP8JSObject+205>:	mov    %rcx,(%rax)
   0x55555772ade0 <_ZN2JSL22ExposeObjectToActiveJSEP8JSObject+208>:	call   0x555556f75a00 <abort>

This is happening extremely frequently and should be fixed as soon as possible. Marking as fuzzblocker.

Attached file Testcase —

Considering the 'extremely frequently', maybe a recent regression from the GC/debugger changes?

Flags: needinfo?(jcoppeard)

Verified bug as reproducible on mozilla-central 20251124094751-7f41ffc04dd6.
The bug appears to have been introduced in the following build range:

Start: b12a28699ba8f9377b1fa055593d3a824637b84e (20251120155949)
End: a7ab407c4b2f588b662a5f6f0a01ec194ddf0e2a (20251120180705)
Pushlog: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=b12a28699ba8f9377b1fa055593d3a824637b84e&tochange=a7ab407c4b2f588b662a5f6f0a01ec194ddf0e2a

Whiteboard: [bugmon:update,bisect][fuzzblocker] → [bugmon:update,bisected,confirmed][fuzzblocker]

The only SpiderMonkey change in that range as far as I can tell is the backout of bug 1989115 which is a bit odd.

(In reply to Andrew McCreight [:mccr8] from comment #5)
It will be bug 2001081 which is just outside that range.

Regressed by: 2001081

Set release status flags based on info from the regressing bug 2001081

Attached file (secure) —

This test found a couple of places where we were triggering the barrier during
sweeping. Neither place requires the barrier.

Assignee: nobody → jcoppeard
Status: NEW → ASSIGNED
Blocks: GC.stability
Severity: -- → S4
Priority: -- → P1
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch

Verified bug as fixed on rev mozilla-central 20251126203239-fc52e8c8d6f1.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.

Status: RESOLVED → VERIFIED
Keywords: bugmon
Flags: needinfo?(jcoppeard)
Keywords: sec-moderate
Comment 7 is private: false
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: