Bug 1013796 - Make TraceGlobal deal with partially created global object. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 20 May 2014 21:44:49 +0200
changeset 203439 322657b30d55f6f78365fd45e48eee979be70dc0
parent 203438 f93935b95229481f6e6a7eb88ea41891b65fb167
child 203440 9789d1e5ee6d1f0b739118bc88eff3306dd3cd88
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1013796
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1013796 - Make TraceGlobal deal with partially created global object. r=bz.
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2428,17 +2428,24 @@ ConvertExceptionToPromise(JSContext* cx,
   return WrapNewBindingObject(cx, promise, rval);
 }
 
 /* static */
 void
 CreateGlobalOptions<nsGlobalWindow>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
 {
   mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj);
-  xpc::GetCompartmentPrivate(aObj)->scope->TraceSelf(aTrc);
+
+  // We might be called from a GC during the creation of a global, before we've
+  // been able to set up the compartment private or the XPCWrappedNativeScope,
+  // so we need to null-check those.
+  xpc::CompartmentPrivate* compartmentPrivate = xpc::GetCompartmentPrivate(aObj);
+  if (compartmentPrivate && compartmentPrivate->scope) {
+    compartmentPrivate->scope->TraceSelf(aTrc);
+  }
 }
 
 /* static */
 bool
 CreateGlobalOptions<nsGlobalWindow>::PostCreateGlobal(JSContext* aCx,
                                                       JS::Handle<JSObject*> aGlobal)
 {
   return XPCWrappedNativeScope::GetNewOrUsed(aCx, aGlobal);