Closed Bug 502914 Opened 15 years ago Closed 15 years ago

JIT code can call js_AddProperty when the property already exists (Assertion failure: !SCOPE_HAS_PROPERTY(scope, sprop), at ../jsbuiltins.cpp:257)

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Assigned: jorendorff)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

function f1() {}
function C() {}
var x = C.prototype = {m: f1};
x.m();  // brand scope
var arr = [new C, new C, new C, x];
for (var i = 0; i < 4; i++) {
    arr[i].m = 12;
    x.m();  // should throw last time through
}

Without -j:
  crasher.js:10: TypeError: x.m is not a function
With -j in a debug build:
  Assertion failure: !SCOPE_HAS_PROPERTY(scope, sprop), at ../jsbuiltins.cpp:257
With -j in a release build, no output.

A harmless correctness bug in the (release) browser, unless it affects any real-world web pages, which I doubt.
Two bugs here. As the summary originally said, we assign a non-function to a function-valued property without bumping the shape. But more importantly, we're calling js_AddProperty here on an object whose scope already contains the desired property. By chance this turns out to be safe, though the behavior is wrong.

I would no longer call this "harmless". It's as important to fix as any assertion.
Summary: Assigning non-function to function-valued property on trace does not change shape (Assertion failure: !SCOPE_HAS_PROPERTY(scope, sprop), at ../jsbuiltins.cpp:257) → JIT code can call js_AddProperty when the property already exists (Assertion failure: !SCOPE_HAS_PROPERTY(scope, sprop), at ../jsbuiltins.cpp:257)
Attached patch v1Splinter Review
Theoretically this makes some property assignments slower, but I saw no change in bench.sh.
Assignee: general → jorendorff
Attachment #387299 - Flags: review?(gal)
Comment on attachment 387299 [details] [diff] [review]
v1

++jorendorff
Attachment #387299 - Flags: review?(gal) → review+
Flags: wanted1.9.1.x?
http://hg.mozilla.org/tracemonkey/rev/6661bcf160cb
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/6661bcf160cb
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
trace-test testBug502914
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: