Closed
Bug 620315
Opened 15 years ago
Closed 15 years ago
"Assertion failure: unexpected constantly false guard detected" with "use strict", 4>this
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla2.0b9
| Tracking | Status | |
|---|---|---|
| blocking2.0 | --- | betaN+ |
People
(Reporter: jruderman, Assigned: Waldo)
Details
(Keywords: assertion, testcase, Whiteboard: fixed-in-tracemonkey)
Attachments
(3 files)
|
3.83 KB,
text/plain
|
Details | |
|
12.80 KB,
patch
|
dmandelin
:
review+
|
Details | Diff | Splinter Review |
|
2.95 KB,
patch
|
dmandelin
:
review+
|
Details | Diff | Splinter Review |
./js -j -m
new Function('"use strict"; for (var j = 0; j < 9; ++j) { 4 > this; }')()
Assertion failure: unexpected constantly false guard detected, at jstracer.cpp:4321
| Reporter | ||
Comment 1•15 years ago
|
||
| Reporter | ||
Comment 2•15 years ago
|
||
The first bad revision is:
changeset: 38cbd4e02afc
user: Jeff Walden
date: Tue Oct 12 11:50:03 2010 -0700
summary: Bug 514570 - 3 - Don't box |this| for strict mode functions. r=jorendorff
| Reporter | ||
Comment 4•15 years ago
|
||
bz, see the big comment near http://hg.mozilla.org/tracemonkey/annotate/8a9c6231fd52/js/src/jstracer.cpp#l4307
| Assignee | ||
Updated•15 years ago
|
Assignee: general → jwalden+bmo
OS: Mac OS X → All
Hardware: x86 → All
Comment 5•15 years ago
|
||
I think this shouldn't block 2.0. Constantly false guards can cause sub-optimal performance but they aren't inherently incorrect or dangerous.
dmandelin, can you mark it blocking2.x?
Comment 6•15 years ago
|
||
Why is this a fatal assert if it's not inherently incorrect?
| Assignee | ||
Comment 7•15 years ago
|
||
new Function functions lack JSFUN_PRIMITIVE_THIS. You can also see the difference with this wrong behavior, interpreter-only (probably reproducible with methodjit too):
var toString = function() { return 5; };
assertEq(new Function("'use strict'; return this > 4;")(), false);
JSFUN_PRIMITIVE_THIS was misguided. It was introduced for natives, but natives always get it as I recall, so it's pointless. Detection based on it really should be for strict mode directly.
This is type confusion (and wrong behavior moreover), so it should block.
| Assignee | ||
Comment 8•15 years ago
|
||
(The effect is regs.fp->computeThis(cx) actually does computeThis here, when it shouldn't.)
Comment 9•15 years ago
|
||
(In reply to comment #6)
>
> Why is this a fatal assert if it's not inherently incorrect?
Because it indicates poor code generation quality, and an assert is the easiest way to get people's attention. Can you think of a better alternative?
(In reply to comment #7)
>
> This is type confusion (and wrong behavior moreover), so it should block.
In that case, fair enough.
Comment 10•15 years ago
|
||
> Can you think of a better alternative?
A debug printf that doesn't kill the browser and hence doesn't interfere with things like fuzz testing, say?
Comment 11•15 years ago
|
||
Well, maybe, though as this case shows it can be due to correctness issues as well. Do debug printfs tend to just get lost/ignored? That's my impression.
Comment 12•15 years ago
|
||
Sure; I was just basing my question on the "this is always safe" claims above...
Updated•15 years ago
|
blocking2.0: ? → -
| Assignee | ||
Comment 13•15 years ago
|
||
I had both these patches finished a bit ago, left them running tests while I ran out to perform an errand -- might as well post them and get this fixed.
Attachment #499447 -
Flags: review?
| Assignee | ||
Comment 14•15 years ago
|
||
Looking at callers, I noticed most to all of them are already called on an interpreted function. It seems reasonable to push that check out to the two calling locations that explicitly need it, keep things a little bit thinner where we can.
Attachment #499449 -
Flags: review?(dmandelin)
| Assignee | ||
Updated•15 years ago
|
Attachment #499447 -
Flags: review? → review?(dmandelin)
Comment 15•15 years ago
|
||
What's the risk level of landing these patches? I'm hesitant to move forward on nonblocking bugs at this point in case they cause regressions.
(Also setting blocking to 2.x per comment 5, which I didn't see earlier.)
blocking2.0: - → .x
| Assignee | ||
Comment 16•15 years ago
|
||
The former is code *removal* and simplification. Risk is low to start, and it's even lower because it makes the code smaller and clearer.
The latter is even less risky -- just splitting up one very-trivial inline method into two separate calls at each caller, most of which already checked (or can trivially assume, e.g. that the function in question *being currently traced* must be interpreted) that the first such call already returned true, so need not be performed.
In comment 7 I argue this is type confusion in the tracer and therefore should block. We only happened to trip over the particular assertion in the original report by dumb luck. You could easily go astray in other ways than just redundantly guarding here, and I am unwilling to give a limit for just how far astray you'd go.
| Assignee | ||
Comment 17•15 years ago
|
||
...plus there are also behavioral differences between tracer and interpreter, and even flat-out bugs where we do things wrong regardless whether tracer, interpreter, or methodjit is configured.
Comment 18•15 years ago
|
||
OK, thanks for the clarification. Will review now.
blocking2.0: .x → betaN+
Updated•15 years ago
|
Attachment #499447 -
Flags: review?(dmandelin) → review+
Comment 19•15 years ago
|
||
Comment on attachment 499449 [details] [diff] [review]
2 - Make JSFunction::inStrictMode assume isInterpreted()
r+ with this addition:
> inline bool
> JSFunction::inStrictMode() const
> {
JS_ASSERT(isInterpreted());
>- return isInterpreted() && u.i.script->strictModeCode;
>+ return script()->strictModeCode;
> }
Attachment #499449 -
Flags: review?(dmandelin) → review+
| Assignee | ||
Comment 20•15 years ago
|
||
(In reply to comment #19)
> r+ with this addition:
>
> > inline bool
> > JSFunction::inStrictMode() const
> > {
>
> JS_ASSERT(isInterpreted());
>
> >- return isInterpreted() && u.i.script->strictModeCode;
> >+ return script()->strictModeCode;
> > }
JSFunction::script() includes that assertion -- seems a nice readability win to rely on this, as I'm pretty sure we do elsewhere. Make sense?
Comment 21•15 years ago
|
||
(In reply to comment #20)
> JSFunction::script() includes that assertion -- seems a nice readability win to
> rely on this, as I'm pretty sure we do elsewhere. Make sense?
Yes. I didn't know that.
| Assignee | ||
Comment 22•15 years ago
|
||
Status: NEW → ASSIGNED
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla2.0b9
Comment 23•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 24•13 years ago
|
||
Automatically extracted testcase for this bug was committed:
https://hg.mozilla.org/mozilla-central/rev/efaf8960a929
Flags: in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•