Closed Bug 618129 Opened 15 years ago Closed 15 years ago

Assertion failure: JSVAL_IS_DOUBLE_IMPL(data)

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: jandem, Assigned: dvander)

References

Details

(Keywords: reporter-external, testcase, Whiteboard: [sg:critical?][hardblocker][fixed-in-tracemonkey])

Attachments

(2 files)

Attached file Test case —
Attached test case triggers this assert in debug builds (JM/TM/interpreter): Assertion failure: JSVAL_IS_DOUBLE_IMPL(data), at ../jsvalue.h:705 It segfaults release builds, both shell and browser, so marking security sensitive.
blocking2.0: --- → ?
I started reducing to see if this was a nan-canonicalization bug. It doesn't seem to be, rather, I think its a bug involving how we touch object slots. I can't reduce it much smaller than this: x = 1; y = 1; this.watch("x", function() { Object.defineProperty(this, "x", ({ get:print })) }); x = 1; Error(); // assert when adding function to global object // while initing Error class
blocking2.0: ? → betaN+
Assignee: general → dvander
Severity: normal → critical
Whiteboard: [sg:critical?]
Bug 622011 trips the same assertion.
Whiteboard: [sg:critical?] → [sg:critical?][hardblocker]
The problem occurs at line 6 in comment #1, possibly within js_NativeSet: sample = cx->runtime->propertyRemovals; { AutoShapeRooter tvr(cx, shape); if (!shape->set(cx, obj, vp)) return false; } At this point, |slot == shape->slot == 191|. shape->set() then sees the obj_watch setter, and invokes it. This redefines the property being altered in js_NativeSet. Then we reach here, if (obj->containsSlot(slot) && where in shape->slot == SHAPE_INVALID_SLOT, but slot is 191. Still investigating, it's not yet clear where the bug is. The slot bookkeeping could be wrong with this setter/watch combination, runtime->propertyRemovals could be wrong, or it could be that js_NativeSet should be reloading shape->slot.
Shared shapes are immutable, so reloading slot won't help. This smells like a slot freelist bug. Want to throw it to me? /be
Sure. It's not shared before shape->set(); it becomes slotless after.
Assignee: dvander → brendan
Keywords: testcase
Attached patch fix? — — Splinter Review
(Taking back to lighten blocker load.) This lead me to bug 624050, which also involved stale shape data. I'm almost convinced shape->slot just needs to be reloaded: Before js_NativeSet() calls shape->set(), the shape has a non-default setter op (js_watch_set, not a setter value, and thus not shared), and a slot (191). shape->set() calls js_watch_set, and the scripted handler evolves the shape to be shared (thus slotless, with a setter value). The old slot is added to the free list, but when js_NativeSet() attempts to update the slot value, it clobbers the free list. The behavior is slightly different in bug 624050, where after shape->set(), then |shape != obj->nativeLookup(shape->id)|. But js_NativeSet checks that the object still contains both the slot and the shape, so this is safe. I'm not sure if js_NativeGet has a similar bug. If so I can't reproduce one, because there's no "watch" for gets.
Assignee: brendan → dvander
Status: NEW → ASSIGNED
Attachment #502163 - Flags: review?(brendan)
If the shape is flagged IN_DICTIONARY then you're right, it is mutable and owned by its object, not shared among objects. Is it changing from slotful to slotless? /be
Yes, that is exactly the change.
So your reload fix resolves this bug? /be
(In reply to comment #12) > So your reload fix resolves this bug? > > /be It fixes the test cases in this bug and its dupes, at least. They all involve watch and defining a getter or setter.
Comment on attachment 502163 [details] [diff] [review] fix? How about adding JS_ASSERT_IF(!obj->inDictionaryMode(), shape->slot == slot); after the set call and before updating slot? More to comment on what is going on than to catch anything super-dire like mutating shared immutable non-dictionary shapes. r=me with that. /be
Attachment #502163 - Flags: review?(brendan) → review+
Whiteboard: [sg:critical?][hardblocker] → [sg:critical?][hardblocker][fixed-in-tracemonkey]
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Group: core-security
Flags: sec-bounty+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: