IonMonkey: Assertion failure: ionInlineFrames_.numActualArgs() <= ionInlineFrames_.callee()->nargs, at vm/Stack.cpp:1496 or Crash [@ js::StackFrame::isFunctionFrame]

RESOLVED FIXED

Status

()

Core
JavaScript Engine
--
major
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: decoder, Assigned: nbp)

Tracking

(Blocks: 2 bugs, {assertion, testcase})

Other Branch
x86_64
Linux
assertion, testcase
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [jsbugmon:update,ignore])

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

5 years ago
The following testcase asserts on ionmonkey revision e8de64e7e9fe (run with --ion -n -m --ion-eager):


function f2() {
  return f2.arguments;
}
actual = (f2() == null);
actual = (f2(0) == null);
(Reporter)

Comment 1

5 years ago
Crashes only in debug build but I cannot judge if that is coincidence or not. Crash trace when stepping through assertions:

Assertion failure: Crossing fingers: Unable to read snapshot slot., at ../ion/IonFrameIterator.h:224

Program received signal SIGABRT, Aborted.

Program received signal SIGSEGV, Segmentation fault.
0x000000000040681c in js::StackFrame::isFunctionFrame (this=0x6d65) at ../../vm/Stack.h:462
462             return !!(flags_ & FUNCTION);
Missing separate debuginfos, use: debuginfo-install libgcc-4.4.6-3.el6.x86_64 libstdc++-4.4.6-3.el6.x86_64
(gdb) bt 8
#0  0x000000000040681c in js::StackFrame::isFunctionFrame (this=0x6d65) at ../../vm/Stack.h:462
#1  0x0000000000639e7c in js::StackFrame::functionScript (this=0x6d65) at ../vm/Stack.h:622
#2  0x00007f0700000002 in ?? ()
#3  0xffffffff00000001 in ?? ()
#4  0x00007fffffffb600 in ?? ()
#5  0x00007fffffffb620 in ?? ()
#6  0x00007f0700000002 in ?? ()
#7  0xffffffff00000001 in ?? ()
(More stack frames follow...)
(gdb) x /i $pc
=> 0x40681c <js::StackFrame::isFunctionFrame() const+12>:       mov    (%rax),%eax
(gdb) info reg rax
rax            0x6d65   28005
(Assignee)

Comment 2

5 years ago
I added this code because this case is not handled yet.  Currently we are not mapping all arguments of the function, only the expected number of arguments and add Undefined arguments as padding if not provided.

So if the number of actual argument is larger than the number of formal argument, which explain why we have this assertion.  Eager compilation cause f2 to be compiled and when f2.arguments tries to create an unexpected argument object, it needs to recover them from the Ion stack.

Sadly we have no current way to detect such cases ahead enough to avoid entering the ion code which is shrinking the argument vector.
Assignee: general → nicolas.b.pierron
Status: NEW → ASSIGNED
(Assignee)

Comment 3

5 years ago
Created attachment 624427 [details] [diff] [review]
f.arguments: Recover overflow of arguments from the stack.

This patch should fix the current bug but it also introduce a problem in case of bailouts with an overflow of arguments which is not yet handled and will be fixed in a follow-up bug/patch.
Attachment #624427 - Flags: review?(dvander)
(Assignee)

Comment 4

5 years ago
Created attachment 624439 [details] [diff] [review]
f.arguments: Recover overflow of arguments from the stack.

The same except that this fix an additional bug SnapshotIterator::hasLocation which raised when I added one formal argument in the test case.
Attachment #624427 - Attachment is obsolete: true
Attachment #624427 - Flags: review?(dvander)
Attachment #624439 - Flags: review?(dvander)
Comment on attachment 624439 [details] [diff] [review]
f.arguments: Recover overflow of arguments from the stack.

Review of attachment 624439 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/ion/Ion.cpp
@@ +960,5 @@
>          argv = fp->formalArgs() - 1;
> +        if (fp->hasOverflowArgs()) {
> +            argc = fp->numActualArgs() + 1;
> +            argv = fp->actualArgs() - 1;
> +        }

nit: It might read better to put the initial argc/argv assignment in an else branch.

::: js/src/ion/IonFrameIterator-inl.h
@@ +65,5 @@
> +        // Currently inlining does not support overflow of arguments, we have to
> +        // add this feature in IonBuilder.cpp and in Bailouts.cpp before
> +        // continuing. We need to add it to Bailouts.cpp because we need to know
> +        // how to walk over the oveflow of arguments.
> +        JS_ASSERT(end <= nformal);

nit: Please brace this if/else (comment makes it multi-line)
Attachment #624439 - Flags: review?(dvander) → review+
(Assignee)

Updated

5 years ago
Blocks: 755979
(Assignee)

Comment 6

5 years ago
https://hg.mozilla.org/projects/ionmonkey/rev/7223b4307198
No longer blocks: 755979
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
(Assignee)

Comment 7

5 years ago
Previous commits have been reverted, due to errors on tbpl.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
status-firefox-esr10: --- → unaffected
(Reporter)

Comment 8

5 years ago
JSBugMon: The testcase found in this bug no longer reproduces (tried revision 8c54899dae82).
(Reporter)

Updated

5 years ago
Whiteboard: [jsbugmon:update] → [jsbugmon:update,ignore]
(Assignee)

Comment 9

5 years ago
https://hg.mozilla.org/projects/ionmonkey/rev/0f9317cf68d2
Group: core-security
Status: REOPENED → RESOLVED
Last Resolved: 5 years ago5 years ago
status-firefox-esr10: unaffected → ---
Resolution: --- → FIXED
(Reporter)

Comment 10

5 years ago
A testcase for this bug was automatically identified at js/src/jit-test/tests/ion/bug754720.js.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.