Closed Bug 591038 Opened 14 years ago Closed 14 years ago

TM: put xpc_NewSystemInheritingJSObject objects into chrome compartment

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gwagner, Assigned: mrbkap)

References

Details

Attachments

(1 file)

this has to go into the right compartment

inline JSObject*
xpc_NewSystemInheritingJSObject(JSContext *cx, JSClass *clasp, JSObject *proto,
                                JSObject *parent)
{
    JSObject *obj;
    if (clasp->flags & JSCLASS_IS_GLOBAL) {
        obj = JS_NewGlobalObject(cx, clasp);
        if (obj && proto)
            JS_SetPrototype(cx, obj, proto);
    } else {
        obj = JS_NewObject(cx, clasp, proto, parent);
    }
    if (obj && JS_IsSystemObject(cx, parent) && !JS_MakeSystemObject(cx, obj))
        obj = NULL;
    return obj;
}
stack:


Assertion failure: cx->compartment != cx->runtime->defaultCompartment, at /Users/idefix2/moz/meter/js/src/jsapi.cpp:2956

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00000001018b785e in JS_Assert (s=0x101c51148 "cx->compartment != cx->runtime->defaultCompartment", file=0x101c50c90 "/Users/idefix2/moz/meter/js/src/jsapi.cpp", ln=2956) at /Users/idefix2/moz/meter/js/src/jsutil.cpp:80
80	    *((int *) NULL) = 0;  /* To continue from here in GDB: "return" then "continue". */
(gdb) bt
#0  0x00000001018b785e in JS_Assert (s=0x101c51148 "cx->compartment != cx->runtime->defaultCompartment", file=0x101c50c90 "/Users/idefix2/moz/meter/js/src/jsapi.cpp", ln=2956) at /Users/idefix2/moz/meter/js/src/jsutil.cpp:80
#1  0x000000010175512f in JS_NewObject (cx=0x106948dd0, jsclasp=0x10278aba0, proto=0x118603990, parent=0x118603948) at /Users/idefix2/moz/meter/js/src/jsapi.cpp:2956
#2  0x0000000100e66957 in xpc_NewSystemInheritingJSObject (cx=0x106948dd0, clasp=0x10278aba0, proto=0x118603990, parent=0x118603948) at xpcinlines.h:739
#3  0x0000000100e7575d in XPCWrappedNativeProto::Init (this=0x106954f80, ccx=@0x7fff5fbfc6b0, isGlobal=0, scriptableCreateInfo=0x7fff5fbfba80) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednativeproto.cpp:137
#4  0x0000000100e75e93 in XPCWrappedNativeProto::GetNewOrUsed (ccx=@0x7fff5fbfc6b0, Scope=0x106949fa0, ClassInfo=0x1069573e0, ScriptableCreateInfo=0x7fff5fbfba80, ForceNoSharing=0, isGlobal=0, offsets=0x1) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednativeproto.cpp:264
#5  0x0000000100e62af1 in XPCWrappedNative::GetNewOrUsed (ccx=@0x7fff5fbfc6b0, Object=0x1069573d0, Scope=0x106949fa0, Interface=0x106954d30, cache=0x0, isGlobal=0, resultWrapper=0x7fff5fbfbd60) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednative.cpp:538
#6  0x0000000100e32a3a in XPCConvert::NativeInterface2JSObject (lccx=@0x7fff5fbfbfa0, d=0x7fff5fbfc180, dest=0x0, src=0x1069573d0, iid=0x7fff5fbfc310, Interface=0x0, cache=0x0, scope=0x118603a20, allowNativeWrapper=1, isGlobal=0, pErr=0x7fff5fbfc1bc, aHelper=0x0) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcconvert.cpp:1239
#7  0x0000000100e34072 in XPCConvert::NativeData2JS (lccx=@0x7fff5fbfbfa0, d=0x7fff5fbfc180, s=0x7fff5fbfc430, type=@0x7fff5fbfc1cc, iid=0x7fff5fbfc310, scope=0x118603a20, pErr=0x7fff5fbfc1bc) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcconvert.cpp:472
#8  0x0000000100e38ec9 in XPCConvert::NativeData2JS (ccx=@0x7fff5fbfc6b0, d=0x7fff5fbfc180, s=0x7fff5fbfc430, type=@0x7fff5fbfc1cc, iid=0x7fff5fbfc310, scope=0x118603a20, pErr=0x7fff5fbfc1bc) at xpcprivate.h:3091
#9  0x0000000100e6922e in CallMethodHelper::GatherAndConvertResults (this=0x7fff5fbfc3f0) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednative.cpp:2603
#10 0x0000000100e69f2c in CallMethodHelper::Call (this=0x7fff5fbfc3f0) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednative.cpp:2362
#11 0x0000000100e634a4 in XPCWrappedNative::CallMethod (ccx=@0x7fff5fbfc6b0, mode=XPCWrappedNative::CALL_GETTER) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednative.cpp:2311
#12 0x0000000100e751e5 in XPCWrappedNative::GetAttribute (ccx=@0x7fff5fbfc6b0) at xpcprivate.h:2587
#13 0x0000000100e6f0f4 in XPC_WN_GetterSetter (cx=0x106948dd0, obj=0x118603a20, argc=0, argv=0x1180002b0, vp=0x118000308) at /Users/idefix2/moz/meter/js/src/xpconnect/src/xpcwrappednativejsops.cpp:1782
#14 0x00000001018055c3 in js::callJSNative (cx=0x106948dd0, native=0x100e6ed96 <XPC_WN_GetterSetter(JSContext*, JSObject*, unsigned int, jsval_layout*, jsval_layout*)>, thisobj=0x118603a20, argc=0, argv=0x1180002b0, rval=0x118000308) at jscntxtinlines.h:554
#15 0x00000001018014c1 in js::InvokeCommon<int (*)(JSContext*, JSObject*, unsigned int, js::Value*, js::Value*)> (cx=0x106948dd0, fun=0x118614870, script=0x0, native=0x100e6ed96 <XPC_WN_GetterSetter(JSContext*, JSObject*, unsigned int, jsval_layout*, jsval_layout*)>, argsRef=@0x7fff5fbfca10, flags=2) at jsinterp.cpp:565
#16 0x00000001018040b7 in js::Invoke (cx=0x106948dd0, args=@0x7fff5fbfca10, flags=2) at jsinterp.cpp:696
#17 0x000000010180467b in js::InternalInvoke (cx=0x106948dd0, thisv=@0x7fff5fbfcab0, fval=@0x7fff5fbfcb80, flags=0, argc=0, argv=0x0, rval=0x7fff5fbfd910) at jsinterp.cpp:736
#18 0x0000000101804718 in js::InternalCall (cx=0x106948dd0, obj=0x118603a20, fval=@0x7fff5fbfcb80, argc=0, argv=0x0, rval=0x7fff5fbfd910) at jsinterp.h:651
#19 0x0000000101804790 in js::InternalGetOrSet (cx=0x106948dd0, obj=0x118603a20, id={asBits = 4336617120}, fval=@0x7fff5fbfcb80, mode=JSACC_READ, argc=0, argv=0x0, rval=0x7fff5fbfd910) at jsinterp.cpp:756
#20 0x000000010182abe7 in JSScopeProperty::get (this=0x107967530, cx=0x106948dd0, obj=0x118603a20, pobj=0x1186039d8, vp=0x7fff5fbfd910) at jsscopeinlines.h:306
#21 0x0000000101820a72 in js_NativeGet (cx=0x106948dd0, obj=0x118603a20, pobj=0x1186039d8, sprop=0x107967530, getHow=3, vp=0x7fff5fbfd910) at /Users/idefix2/moz/meter/js/src/jsobj.cpp:4685
#22 0x0000000101820fd3 in js_GetPropertyHelper (cx=0x106948dd0, obj=0x118603a20, id={asBits = 4336617120}, getHow=3, vp=0x7fff5fbfd910) at /Users/idefix2/moz/meter/js/src/jsobj.cpp:4853
#23 0x00000001018210b9 in js_GetMethod (cx=0x106948dd0, obj=0x118603a20, id={asBits = 4336617120}, getHow=3, vp=0x7fff5fbfd910) at /Users/idefix2/moz/meter/js/src/jsobj.cpp:4876
#24 0x00000001017ec2da in js::Interpret (cx=0x106948dd0) at /Users/idefix2/moz/meter/js/src/jsinterp.cpp:4108
#25 0x0000000101803884 in js::Execute (cx=0x106948dd0, chain=0x118603948, script=0x105434440, down=0x0, flags=0, result=0x7fff5fbfe3c0) at jsinterp.cpp:881
#26 0x0000000101753dea in JS_ExecuteScript (cx=0x106948dd0, obj=0x118603948, script=0x105434440, rval=0x7fff5fbfe3c0) at /Users/idefix2/moz/meter/js/src/jsapi.cpp:4821
#27 0x0000000100f257a2 in mozJSComponentLoader::GlobalForLocation (this=0x106948870, aComponentFile=0x106a2a7d0, aURI=0x106948a60, aGlobal=0x106948c30, aLocation=0x106948c38, exception=0x0) at /Users/idefix2/moz/meter/js/src/xpconnect/loader/mozJSComponentLoader.cpp:1503
#28 0x0000000100f2750d in mozJSComponentLoader::LoadModuleImpl (this=0x106948870, aSourceFile=0x106a2a7d0, aKey=@0x7fff5fbfe890, aComponentURI=0x106948a60) at /Users/idefix2/moz/meter/js/src/xpconnect/loader/mozJSComponentLoader.cpp:793
#29 0x0000000100f27e4a in mozJSComponentLoader::LoadModule (this=0x106948870, aComponentFile=0x106a2a7d0) at /Users/idefix2/moz/meter/js/src/xpconnect/loader/mozJSComponentLoader.cpp:728
#30 0x0000000101576e77 in nsComponentManagerImpl::KnownModule::Load (this=0x106a2a460) at /Users/idefix2/moz/meter/xpcom/components/nsComponentManager.cpp:929
#31 0x0000000101576f81 in nsFactoryEntry::GetFactory (this=0x106a2a4c0) at /Users/idefix2/moz/meter/xpcom/components/nsComponentManager.cpp:1918
#32 0x0000000101577278 in nsComponentManagerImpl::CreateInstanceByContractID (this=0x1069077a0, aContractID=0x106948808 "@mozilla.org/weave/service;1", aDelegate=0x0, aIID=@0x101c81e70, aResult=0x7fff5fbfebd0) at /Users/idefix2/moz/meter/xpcom/components/nsComponentManager.cpp:1280
#33 0x0000000101575ed3 in nsComponentManagerImpl::GetServiceByContractID (this=0x1069077a0, aContractID=0x106948808 "@mozilla.org/weave/service;1", aIID=@0x101c81e70, result=0x7fff5fbfece8) at /Users/idefix2/moz/meter/xpcom/components/nsComponentManager.cpp:1646
#34 0x0000000101504b31 in CallGetService (aContractID=0x106948808 "@mozilla.org/weave/service;1", aIID=@0x101c81e70, aResult=0x7fff5fbfece8) at nsComponentManagerUtils.cpp:94
#35 0x0000000101504b62 in nsGetServiceByContractIDWithError::operator() (this=0x7fff5fbfed90, aIID=@0x101c81e70, aInstancePtr=0x7fff5fbfece8) at nsComponentManagerUtils.cpp:288
#36 0x000000010150386b in nsCOMPtr_base::assign_from_gs_contractid_with_error (this=0x7fff5fbfee00, gs=@0x7fff5fbfed90, iid=@0x101c81e70) at nsCOMPtr.cpp:141
#37 0x0000000100fb0ac4 in nsCOMPtr<nsISupports>::operator= (this=0x7fff5fbfee00, rhs=@0x7fff5fbfed90) at nsCOMPtr.h:1054
#38 0x0000000100fb041c in nsAppStartupNotifier::Observe (this=0x106948730, aSubject=0x0, aTopic=0x101b0f01a "app-startup", someData=0x0) at /Users/idefix2/moz/meter/embedding/components/appstartup/src/nsAppStartupNotifier.cpp:100
#39 0x000000010002e1c3 in XRE_main (argc=1, argv=0x7fff5fbff8b0, aAppData=0x105415bd0) at /Users/idefix2/moz/meter/toolkit/xre/nsAppRunner.cpp:3494
#40 0x0000000100001297 in main (argc=1, argv=0x7fff5fbff8b0) at /Users/idefix2/moz/meter/browser/app/nsBrowserApp.cpp:158
Attached patch patch (deleted) — Splinter Review
Gregor, do you have a few cycles to test that this patch fixes this bug?
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Attachment #470613 - Flags: review?(gal)
Attachment #470613 - Flags: feedback?(anygregor)
Attachment #470613 - Flags: review?(gal) → review+
Comment on attachment 470613 [details] [diff] [review]
patch

Works!
Attachment #470613 - Flags: feedback?(anygregor) → feedback+
Blocks: 594455
Was this landed?
Yep.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: