Closed
Bug 501986
Opened 15 years ago
Closed 15 years ago
Assertion failure: JSVAL_IS_VOID(STOBJ_GET_SLOT(obj, scope->freeslot)), at ../jsobj.cpp:3446
Categories
(Core :: JavaScript Engine, defect, P1)
Tracking
()
VERIFIED
FIXED
Tracking | Status | |
---|---|---|
status1.9.2 | --- | beta1-fixed |
blocking1.9.1 | --- | - |
status1.9.1 | --- | wontfix |
People
(Reporter: jorendorff, Assigned: jorendorff)
References
Details
(Keywords: verified1.9.2, Whiteboard: [sg:critical][needs answer to comment 22 from jorendorff/brendan] fixed-in-tracemonkey)
Attachments
(1 file)
(deleted),
patch
|
Details | Diff | Splinter Review |
record_SetPropHit does not emit a check for objects that share their prototype's shape.
function D() {}
var b = D.prototype = {x: 1};
var d = new D;
var arr = [b, b, b, d]; // all same shape, but d has no slot for x
for (var i = 0; i < 4; i++)
arr[i].x = i; // code emitted here does the wrong thing when arr[i]===d.
d.y = 12; // Assertion failure: JSVAL_IS_VOID(
STOBJ_GET_SLOT(obj, scope->freeslot)), at ../jsobj.cpp:3446
assertEq(d.x, 3); // TypeError: Assertion failed: got 2, expected 3
The quickest way to fix this bug is to add a guard in the JIT. But prototype-scope-sharing has led to other bugs (such as bug 501690) and makes shape generally less useful for the JIT, which really wants to believe that shape defines layout. Inserting a guard will make us slower on every property set. I think it's time for prototype-scope-sharing to go. (Bug 497789 comment 39 again.)
Updated•15 years ago
|
Flags: blocking1.9.2?
Flags: blocking1.9.1.1?
Assignee | ||
Comment 1•15 years ago
|
||
I don't know if this is exploitable, but if you put N properties on b, instead of just 1, then you can write any odd number you like to memory location ((int *)0 + (N-3)) ...or something like that.
For example, I was able to produce this by putting 10000 properties on b:
==4718== Address 0x9c34 is not stack'd, malloc'd or (recently) free'd
I imagine that is far short of any actual mapped pages, though.
Group: core-security
Updated•15 years ago
|
Whiteboard: [sg:critical]
Assignee | ||
Comment 2•15 years ago
|
||
Taking. This needs to be patched on the branch pronto, so I'll just add the guard and slow down every property set. Maybe it won't be measurable.
Bug 503080 is the followup bug for killing prototype-scope-sharing.
Assignee: general → jorendorff
Assignee | ||
Comment 3•15 years ago
|
||
The same bug affects test_property_cache, i.e. reads as well as writes. offsetof(JSScope, object) does not currently appear in jstracer.cpp.
Patch with extra guards coming in a few hours.
Assignee | ||
Comment 4•15 years ago
|
||
Extra review from Andreas would be welcome. Is MISMATCH_EXIT the right exit type here?
This patch guards against objects that share their prototype's scope, when that prototype is *not* the global object.
Technically the global object needs this guard too, if it is possible for an object to share its scope with the global object. But that would require the embedding to do something weird, namely create an object that has the same number of reserved slots as a global and also has the global as its prototype.
(More generally I don't understand the JIT's assumptions regarding the global object. Does the global object necessarily have a branded scope? a unique shape? Must it have JSCLASS_GLOBAL_FLAGS? In some places we seem to assume that if obj == global at record time, then the same will be true at run time. Do we really assume that? How do we know?)
Attachment #387644 -
Flags: review?(brendan)
Comment 5•15 years ago
|
||
(In reply to comment #4)
> Technically the global object needs this guard too, if it is possible for an
> object to share its scope with the global object. But that would require the
> embedding to do something weird, namely create an object that has the same
> number of reserved slots as a global and also has the global as its prototype.
We should rule that out, assertions ought to be enough. But where?
> (More generally I don't understand the JIT's assumptions regarding the global
> object. Does the global object necessarily have a branded scope?
No, but its shape can't change.
> a unique shape?
We do not require uniqueness since we trigger traces only for matching object pointer, not shape.
> Must it have JSCLASS_GLOBAL_FLAGS?
Hadn't thought of that, it's a good thing (doing otherwise is bad for modern, codified-in-ES5 "original value of Object.prototype" memoization). Where do you see a dependency?
> In some places we seem to assume that
> if obj == global at record time, then the same will be true at run time. Do we
> really assume that? How do we know?)
See getLoop and under.
/be
Comment 6•15 years ago
|
||
Bet the extra guard will cause noticeable slowdown. Since this was discovered by you, perhaps we could cut to the chase and fix only bug 503080 -- whaddya think?
/be
Assignee | ||
Comment 7•15 years ago
|
||
I'd prefer to fix bug 503080, but that will be a big, moderately risky patch, and hard to backport. We urgently need a patch for this that can land in 1.9.1.
Tomorrow morning I plan to measure the performance hit with v1. If there is no measurable loss on any of the usual benchmarks, I want to check this into tracemonkey.
But even if we lose a percent or two, I will backport that patch to 1.9.1 and request approval to land it (unless there's a better way).
Comment 8•15 years ago
|
||
Let's work on bug 503080 a bit more -- time is an issue but not paramount yet.
/be
Assignee | ||
Comment 9•15 years ago
|
||
As of right now, bug 503080 is not "almost done"; it depends on bug 503860 which depends on bug 497789 which looks like a stumper to me.
Leaning towards the plan in comment 7, to hedge bets.
Updated•15 years ago
|
blocking1.9.1: --- → needed
status1.9.1:
--- → wanted
Flags: wanted1.9.1.x+
Flags: blocking1.9.1.1?
Flags: blocking1.9.1.1-
Comment 10•15 years ago
|
||
Any perf news? If we can add the guard without regression, I'm in favor.
/be
Assignee | ||
Comment 11•15 years ago
|
||
Well... now bug 503080 is almost done!
Assignee | ||
Comment 12•15 years ago
|
||
Bug 503080 is fixed-in-tracemonkey.
Scroll down to the bottom of
http://hg.mozilla.org/tracemonkey/rev/3915e2d2c748
to see the test case from comment 0 added to trace-test.js.
Whiteboard: [sg:critical] → [sg:critical] fixed-in-tracemonkey
Comment 13•15 years ago
|
||
Comment on attachment 387644 [details] [diff] [review]
v1
Would like perf measures to see whether we could slip this into a dot release.
/be
Updated•15 years ago
|
Flags: blocking1.9.2? → blocking1.9.2+
Priority: -- → P1
Comment 14•15 years ago
|
||
This is marked as blocking Firefox 3.6a1, any ETA? Should it not block that milestone?
Assignee | ||
Comment 15•15 years ago
|
||
OK, time to get something landed in the branch.
Beltzner, would you rather have the 9KB patch in this bug that narrowly fixes the issue, isn't tested, and would make future merges more difficult ...or the 64KB patch in bug 503080 (and the teensy followup fix in bug 506347) that probably fixes other undiscovered issues and has landed in tm and m-c?
Assignee | ||
Comment 16•15 years ago
|
||
Fixed in m-c as well, as of 7-24.
http://hg.mozilla.org/mozilla-central/rev/3915e2d2c748
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•15 years ago
|
Attachment #387644 -
Flags: review?(brendan)
Comment 17•15 years ago
|
||
(In reply to comment #15)
> Beltzner, would you rather have the 9KB patch in this bug that narrowly fixes
> the issue, isn't tested, and would make future merges more difficult ...or the
> 64KB patch in bug 503080 (and the teensy followup fix in bug 506347) that
> probably fixes other undiscovered issues and has landed in tm and m-c?
Assuming you mean for 1.9.1.x (the Firefox 3.5.x releases) then I would probably want the patch that you guys feel most securely about. Given the above, that would likely be the larger patch, but we'd still want to see:
- bake time on mozilla-central (shipping it in the 3.6 alpha will give us confidence here, as well)
- good test coverage
- an explanation of why you're confident that it doesn't add risk (regression testing, etc)
- a reviewed branch-safe patch, obviously :)
Comment 18•15 years ago
|
||
Mass change: adding fixed1.9.2 keyword
(This bug was identified as a mozilla1.9.2 blocker which was fixed before the mozilla-1.9.2 repository was branched (August 13th, 2009) as per this query: http://is.gd/2ydcb - if this bug is not actually fixed on mozilla1.9.2, please remove the keyword. Apologies for the bugspam)
Keywords: fixed1.9.2
Comment 19•15 years ago
|
||
It looks to me like bug 503080 now has more than one follow up. Are we sure it's stable and ready for the 1.9.1 branch? If not, can we just take this, safer, targeted fix for 1.9.1?
Updated•15 years ago
|
status1.9.2:
--- → beta1-fixed
Keywords: fixed1.9.2
Updated•15 years ago
|
Whiteboard: [sg:critical] fixed-in-tracemonkey → [sg:critical][needs answer to comment 19 from jorendorff] fixed-in-tracemonkey
Comment 20•15 years ago
|
||
My two cents: you're better off taking the common code. The spot-fix patch here is unreviewed and has no miles on perf-testing infra.
Apart from one dependency of bug 503080 which I think you don't need to worry about (jorendorff please correct me), the work for bug 503080 including followups looks "done" and "baked" to me.
/be
Updated•15 years ago
|
Flags: wanted1.9.1.x+
Comment 21•15 years ago
|
||
comment #12 notes the test added to js/src/trace-test.js in http://hg.mozilla.org/tracemonkey/rev/3915e2d2c748
Flags: in-testsuite+
Comment 22•15 years ago
|
||
(In reply to comment #20)
> Apart from one dependency of bug 503080 which I think you don't need to worry
> about (jorendorff please correct me), the work for bug 503080 including
> followups looks "done" and "baked" to me.
I'm confused. The one dependency you mention is, I'm assuming, bug 503860, which in turn has 10 dependencies in its dependency tree itself. That seem scary to me simply by the amount of dependencies. Is that really not something we should be worrying about?
Likewise, bug 514222 will need to be fixed if we take bug 503080, but it still has an open dependency (bug 514454), which is explicitly titled "Fix all the bugs introduced by the patch in bug 514222". That scares me and makes me think that bug 514222 wasn't ready to land and certainly isn't ready to land on the stable branch. It also hasn't been touched since early September...
Where do we stand on this?
Updated•15 years ago
|
Whiteboard: [sg:critical][needs answer to comment 19 from jorendorff] fixed-in-tracemonkey → [sg:critical][needs answer to comment 22 from jorendorff/brendan] fixed-in-tracemonkey
Comment 23•15 years ago
|
||
testBug501690|testObjectVsPrototype
v 1.9.3, 1.9.2
Status: RESOLVED → VERIFIED
Keywords: verified1.9.2
Updated•14 years ago
|
blocking1.9.1: needed → -
Updated•13 years ago
|
Group: core-security
You need to log in
before you can comment on or make changes to this bug.
Description
•