Closed Bug 520164 Opened 15 years ago Closed 15 years ago

Crash [@ JS_Enumerate] or "Assertion failure: obj->map->ops->defineProperty == js_DefineProperty" with eval

Categories

(Core :: JavaScript Engine, defect, P2)

x86
macOS
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jruderman, Assigned: mrbkap)

References

Details

(4 keywords, Whiteboard: [ccbr] fixed-in-tracemonkey)

Crash Data

Attachments

(1 file, 1 obsolete file)

eval("var a;", <x/>)

Assertion failure: obj->map->ops->defineProperty == js_DefineProperty, at ../jsops.cpp:2938
autoBisect shows this is probably related to TM changeset eec5815b761f or bug 519129:

The first bad revision is:
changeset:   33294:eec5815b761f
user:        Blake Kaplan
date:        Tue Sep 29 10:03:42 2009 -0700
summary:     Fix Zimbra indirect eval crash. r=brendan
Blocks: 519129
Keywords: regression
eval("var a;", [])

asserts too. E4X isn't needed.

Tested on http://hg.mozilla.org/tracemonkey/rev/07e524d2a503
Summary: "Assertion failure: obj->map->ops->defineProperty == js_DefineProperty" with eval, e4x → "Assertion failure: obj->map->ops->defineProperty == js_DefineProperty" with eval
$ cat w6664-cmpin.js 
try { (function() { "" > x })() } catch(e) {}
gc()
try {
    eval("\
         for (var a = 0; a < 1; a++) {\
    for (var b = 0; b < 1; b++) 0\
    }", x = [])
} catch(e) {}
uneval(this)
$ ./js-opt-tm-darwin w6664-cmpin.js 
Segmentation fault

(sometimes Illegal Instruction, exit code 132?)

crashes js opt shell on TM tip without -j at JS_Enumerate near null and asserts js debug shell without -j at Assertion failure: obj->map->ops->defineProperty == js_DefineProperty, at ../jsops.cpp:2934


Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000028
Crashed Thread:  0

Thread 0 Crashed:
0   js-opt-tm-darwin              	0x00011405 JS_Enumerate + 69
1   js-opt-tm-darwin              	0x00067b9a __ZL16MarkSharpObjectsP9JSContextP8JSObjectPP9JSIdArray + 250
2   js-opt-tm-darwin              	0x00067d09 __ZL16MarkSharpObjectsP9JSContextP8JSObjectPP9JSIdArray + 617
3   js-opt-tm-darwin              	0x00067d09 __ZL16MarkSharpObjectsP9JSContextP8JSObjectPP9JSIdArray + 617
4   js-opt-tm-darwin              	0x00067ef7 js_EnterSharpObject + 311
5   js-opt-tm-darwin              	0x0006946c __ZL12obj_toSourceP9JSContextjPl + 220
6   js-opt-tm-darwin              	0x0005e986 js_Invoke + 1606
7   js-opt-tm-darwin              	0x0005f0fb js_InternalInvoke + 139
8   js-opt-tm-darwin              	0x0006e46d js_TryMethod + 285
9   js-opt-tm-darwin              	0x000c848c js_ValueToSource + 380
10  js-opt-tm-darwin              	0x000c84e8 __ZL10str_unevalP9JSContextjPl + 40
11  js-opt-tm-darwin              	0x00057e80 js_Interpret + 39904
12  js-opt-tm-darwin              	0x0005e03a js_Execute + 362
13  js-opt-tm-darwin              	0x0000d65c JS_ExecuteScript + 60
14  js-opt-tm-darwin              	0x000041e8 __ZL7ProcessP9JSContextP8JSObjectPci + 1336
15  js-opt-tm-darwin              	0x000082a4 main + 2212
16  js-opt-tm-darwin              	0x0000217b _start + 209
17  js-opt-tm-darwin              	0x000020a9 start + 41
Keywords: crash
Summary: "Assertion failure: obj->map->ops->defineProperty == js_DefineProperty" with eval → Crash [@ JS_Enumerate] or "Assertion failure: obj->map->ops->defineProperty == js_DefineProperty" with eval
Whiteboard: [ccbr]
Flags: blocking1.9.2+
Priority: -- → P2
jsfunfuzz hits this frequently, even on ARM.
mrbkap, you catch this with other patches?
Assignee: general → mrbkap
Attached patch Proposed fix (obsolete) — Splinter Review
ML objects are so special they make me want to scream... If this is an indirect call, then the scope object is necessarily already a global object.
Attachment #409071 - Flags: review?(igor)
Comment on attachment 409071 [details] [diff] [review]
Proposed fix

>@@ -1393,16 +1393,25 @@ obj_eval(JSContext *cx, JSObject *obj, u
> 
>+        if (!OBJ_IS_NATIVE(scopeobj) || OBJECT_IS_XML(cx, scopeobj)) {

The "if" should check if scopeobj->map->ops->defineProperty is js_DefaultProperty to cover all cases like, for example, liveConnect objects that are still alive on 1.9.2. 

I also think that we should create the with object whenever scopeobj.parent is not null to avoid more surprises like the future.
Attachment #409071 - Flags: review?(igor) → review-
Attached patch With thatSplinter Review
Attachment #409071 - Attachment is obsolete: true
Attachment #409129 - Flags: review?(igor)
Comment on attachment 409129 [details] [diff] [review]
With that

>+        if (scopeobj->getParent() ||
>+            scopeobj->map->ops->defineProperty != js_DefineProperty) {

Final nit: add a comments that refers to this bug that we do not want to have an arbitrary object on the scope chain.
Attachment #409129 - Flags: review?(igor) → review+
(In reply to comment #7)
> I also think that we should create the with object whenever scopeobj.parent is
> not null to avoid more surprises like the future.

To be specific: currently only global, Call, With, Block and DOM event handlers can present on the scope chain. My worry is that if allow arbitrary objects on the scope chain, that may expose hidden bugs or lead to undesirable semantics. Hence the idea to avoid that and boxing surprises using With.
Gary, thanks for requesting checkin-needed, but in this case the patch in the bug is *not* ready for checkin yet (and I don't think the people who do checkin-needed triage are responsible for addressing review comments.
Keywords: checkin-needed
http://hg.mozilla.org/tracemonkey/rev/b10d4f42ce96 with the comment. I noticed that the explicit test for the map->ops->defineProperty hook was unnecessary because any object with a null parent is a global object (and therefore must be a native object).
Whiteboard: [ccbr] → [ccbr] fixed-in-tracemonkey
(In reply to comment #11)
> Gary, thanks for requesting checkin-needed, but in this case the patch in the
> bug is *not* ready for checkin yet (and I don't think the people who do
> checkin-needed triage are responsible for addressing review comments.

Apologies - thanks for the clarification!
http://hg.mozilla.org/mozilla-central/rev/b10d4f42ce96
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
sayrer: this shouldn't block 1.9.2: the regressing patch never landed there (and won't land before final for sure).
Flags: blocking1.9.2+ → blocking1.9.2?
Flags: blocking1.9.2? → blocking1.9.2-
Crash Signature: [@ JS_Enumerate]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: