Closed Bug 1174544 Opened 11 years ago Closed 10 years ago

Crash [@ js::FrameIter::updatePcQuadratic]

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Tracking Status
firefox41 --- affected

People

(Reporter: decoder, Unassigned)

Details

(Keywords: crash, regression, testcase, Whiteboard: [jsbugmon:update])

Crash Data

The following testcase crashes on mozilla-central revision c223b8844264 (build with --enable-optimize --enable-posix-nspr-emulation --enable-valgrind --enable-gczeal --disable-tests --enable-debug, run with --fuzzing-safe --thread-count=2 --ion-extra-checks --ion-eager --ion-offthread-compile=off): var g = newGlobal(); g.eval('function f(a) { if (a == 1) debugger; evaluate("f(" + a + "- 1);", {newContext: true}); }'); var N = 9; var dbg = new Debugger(g); var frames = []; dbg.onEnterFrame = function (frame) { frames.push(frame); frame.onPop = function () { dbg.getNewestFrame().environment; } }; dbg.onDebuggerStatement = function () { for (var f of frames) f.eval('a').return }; eval("g.f(N);"); Backtrace: Program received signal SIGSEGV, Segmentation fault. js::FrameIter::updatePcQuadratic (this=0x7ffffffe73f8) at js/src/vm/Stack.cpp:1065 #0 js::FrameIter::updatePcQuadratic (this=0x7ffffffe73f8) at js/src/vm/Stack.cpp:1065 #1 0x0000000000661240 in DebuggerFrame_getEnvironment (cx=0x7ffff691c920, argc=<optimized out>, vp=<optimized out>) at js/src/vm/Debugger.cpp:5910 #2 0x00007ffff7f9fb2c in ?? () #3 0xfffc7ffff7e645e0 in ?? () #4 0x00007ffffffe7b90 in ?? () #5 0x0000000000000000 in ?? () rax 0x5a5a5a5a5a5a5a5a 6510615555426900570 rbx 0x7ffffffe73f8 140737488253944 rcx 0x0 0 rdx 0x2 2 rsi 0x7ffff695c000 140737330397184 rdi 0x7ffffffe72f0 140737488253680 rbp 0x7ffffffe7350 140737488253776 rsp 0x7ffffffe72f0 140737488253680 r8 0x3c 60 r9 0x3f 63 r10 0x4 4 r11 0x3 3 r12 0x7ffffffe9c90 140737488264336 r13 0x7ffffffe9ba8 140737488264104 r14 0x7ffffffe72f0 140737488253680 r15 0x7ffffffe7448 140737488254024 rip 0x7328cc <js::FrameIter::updatePcQuadratic()+92> => 0x7328cc <js::FrameIter::updatePcQuadratic()+92>: mov 0x160(%rax),%rdx 0x7328d3 <js::FrameIter::updatePcQuadratic()+99>: mov %rdx,-0x60(%rbp) Assuming it's not s-s because it involves the debugger.
The test that the fuzzer generated here truly is evil. First, some background on Debugger.Frame instances. When they're first created, they are internally represented by an AbstractFramePtr, which is basically a pointer that doesn't know anything about where it is on the stack. Lazily, if needed, an FrameIter is constructed. And since we don't want to re-construct the FrameIter each time we need it, after the first time the Debugger.Frame instance caches the FrameIter and the iter becomes its canonical representation -- as opposed to the AbstractFramePtr. FrameIters are intrinsically tied to the JSContext they're created in. The test, again, with some comments: var g = newGlobal(); g.eval('function f(a) { if (a == 1) debugger; evaluate("f(" + a + "- 1);", {newContext: true}); }'); var N = 2; var dbg = new Debugger(g); var frames = []; dbg.onEnterFrame = function (frame) { // Save the frames for calling .eval on later. frames.push(frame); frame.onPop = function () { frame.environment; } }; dbg.onDebuggerStatement = function () { // When this is called for the first time is when the 'f' function above // has bottomed out. This happens under a *new, different* JSContext // than frames[0] was created in, because of evaluate(..., {newContext:true}). for (var f of frames) { f.eval('a').return } }; eval("g.f(N);"); The very first Debugger.Frame created, under the original JSContext (let's call this cx1) is pushed to |frames[0]|. At this point, it is backed by an AbstractFramePtr. Eventually we get to the onDebuggerStatement call, which calls eval on |frames[0]|. This constructs a FrameIter under the context of the |evaluate(..., {newContext:true})| (let's call this cx2), and caches it in the Debugger.Frame. Then, the |evaluate(..., {newContext:true}| call returns, and it manually destroys cx2. Finally, the frame associated with |frames[0]| is popped. But remember that at this point, |frames[0]| is represented by a FrameIter tied to cx2, which has been freed. This causes the crash. I guess the fix here would be to instantiate the Debugger.Frame FrameIters with the Debugger cx? Sometime later, when |frames[0]| is actually popped,
Whiteboard: [jsbugmon:update,bisect] → [jsbugmon:update]
JSBugMon: Bisection requested, result: === Treeherder Build Bisection Results by autoBisect === The "good" changeset has the timestamp "20150515145345" and the hash "da253a87bcf6". The "bad" changeset has the timestamp "20150520090144" and the hash "a8182dab4c18". Likely regression window: https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=da253a87bcf6&tochange=a8182dab4c18
Whiteboard: [jsbugmon:update] → [jsbugmon:]
JSBugMon: Cannot process bug: Unable to automatically reproduce, please track manually.
Whiteboard: [jsbugmon:] → [jsbugmon:update]
Whiteboard: [jsbugmon:update] → [jsbugmon:update,ignore]
JSBugMon: The testcase found in this bug no longer reproduces (tried revision ad16863d1d45).
Whiteboard: [jsbugmon:update,ignore] → [jsbugmon:bisectfix]
Whiteboard: [jsbugmon:bisectfix] → [jsbugmon:]
JSBugMon: Fix Bisection requested, result: autoBisect shows this is probably related to the following changeset: The first good revision is: changeset: https://hg.mozilla.org/mozilla-central/rev/80dbbf6dab20 user: Shu-yu Guo date: Wed Aug 12 16:37:07 2015 -0700 summary: Bug 1161332 - Don't save the JSContext when saving FrameIter::Data. (r=jimb) This iteration took 239.637 seconds to run.
Shu-yu, is bug 1161332 a likely fix?
Flags: needinfo?(shu)
(In reply to Gary Kwong [:gkw] [:nth10sd] from comment #6) > Shu-yu, is bug 1161332 a likely fix? Yes. I don't know what happened in comment 1 either, looks like I fell asleep in the middle of writing it or something.
Flags: needinfo?(shu)
Resolving FIXED by bug 1161332.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [jsbugmon:] → [jsbugmon:update]
You need to log in before you can comment on or make changes to this bug.