nsXBLProtoImplProperty::InstallMember doesn't root correctly because it doesn't give its temporary variable a name! (LXR says this is the only use of nsAutoGCRoot with this problem.)
Created attachment 212308 [details] [diff] [review] patch The first chunk is the important one, the rest is cleanup that I've had in my tree for ages (the call used to require a cx argument, it no loner does).
Actually, we need to root the setter too, because DefineUCProperty can cause GC: js_GC (/builds/trunk/mozilla/js/src/jsgc.c:1947) js_NewGCThing (/builds/trunk/mozilla/js/src/jsgc.c:635) AllocSlots (/builds/trunk/mozilla/js/src/jsobj.c:1925) js_NewObject (/builds/trunk/mozilla/js/src/jsobj.c:2052) js_CloneFunctionObject (/builds/trunk/mozilla/js/src/jsfun.c:2070) JS_CloneFunctionObject (/builds/trunk/mozilla/js/src/jsapi.c:3414) xpc_CloneJSFunction(XPCCallContext&, JSObject*, JSObject*) (/builds/trunk/mozilla/js/src/xpconnect/src/xpcwrappednativeinfo.cpp:56) DefinePropertyIfFound (/builds/trunk/mozilla/js/src/xpconnect/src/xpcwrappednativejsops.cpp:453) XPC_WN_ModsAllowed_Proto_Resolve (/builds/trunk/mozilla/js/src/xpconnect/src/xpcwrappednativejsops.cpp:1574) js_LookupPropertyWithFlags (/builds/trunk/mozilla/js/src/jsobj.c:2801) js_LookupProperty (/builds/trunk/mozilla/js/src/jsobj.c:2660) js_DefineNativeProperty (/builds/trunk/mozilla/js/src/jsobj.c:2524) js_DefineProperty (/builds/trunk/mozilla/js/src/jsobj.c:2469) DefineUCProperty (/builds/trunk/mozilla/js/src/jsapi.c:2381)
Created attachment 212309 [details] [diff] [review] patch
Comment on attachment 212309 [details] [diff] [review] patch r+sr=bzbarsky, but we need similar changes to root newly-cloned function objects across JS_DefineUCProperty in nsXBLProtoImplMethod::InstallMember and the code added in bug 307040. It looks like thanks to the wonders of XPConnect, Brendan's bug 299205 comment 10 is not quite right. :( We probably want this on both 1.8 branches.
Fix checked in to trunk.
11 years ago
Checked in to MOZILLA_1_8_BRANCH.
Can we get some info about how this affect people in the wild? How will this benefit the users? We need this benefit before we can approve the patch for 18.104.22.168.
Since some null checks are being removed by this patch, we'd like a little more clarity w.r.t. risk before accepting this patch. Can someone please address Tim's question (comment #8). Thanks!
> Since some null checks are being removed by this patch, The null checks being removed were holdovers from back when we actually used the |cx| object there (to root stuff). We don't anymore, so it's not an issue whether cx is null (not that it ever can be in this case). As for comment 8, this just makes sure we don't access deleted objects by keeping them alive while we're working with them. The effect should be fewer random exploitable deleted-memory-access crashes and nothing else.
The null-check removals were just cleanup -- very low risk cleanup, though. But I could easily skip that part of the patch for a 1.8.0 branch landing.
For crying out loud... Read http://lxr.mozilla.org/mozilla/source/content/base/src/nsContentUtils.cpp#2552 and note that there is no dependency on a (JSContext *) cx cast from any aContext that is *not* passed to nsContentUtils::AddJSGCRoot. The whole GetNativeContext call, assignment to cx, and test of cx are useless. The patch should be taken in full, fiddling to remove these null check removals is a waste of time and a minor but non-zero merge hazard. /be
Comment on attachment 212309 [details] [diff] [review] patch approved for 1.8.0 branch, a=dveditz for drivers
Fix checked in to MOZILLA_1_8_0_BRANCH.
v.fixed on 1.8.0 branch: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:22.214.171.124) Gecko/20060420 Firefox/126.96.36.199, based on code inspection and brendan's comments.