Bug 1585819 - Somewhat dubiously appease the hazard analysis. r=bustage
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 03 Oct 2019 06:35:33 +0200
changeset 496150 0c7e2e49aa842ae37ab278a0a7ff814695fcb71a
parent 496149 45b2d685bc5f97e7a4d8128dd0aabd1b2f2f5e75
child 496151 6e8f0afa223c278413b9f5464200d71451650461
push id97054
push useremilio@crisal.io
push dateThu, 03 Oct 2019 04:38:43 +0000
treeherderautoland@0c7e2e49aa84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1585819
milestone71.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 1585819 - Somewhat dubiously appease the hazard analysis. r=bustage It was complaining about "unrooted '<returnvalue>' of type 'JSObject*' live across GC call at dom/base/Element.cpp:588" Where the GC call is: Function '_ZN7mozilla3dom7Element10WrapObjectEP9JSContextN2JS6HandleIP8JSObjectEE$JSObject* mozilla::dom::Element::WrapObject(JSContext*, JS::Handle<JSObject*>)' has unrooted '<returnvalue>' of type 'JSObject*' live across GC call '_ZN6RefPtrI12nsXBLBindingED1Ev$RefPtr<T>::~RefPtr() [with T = nsXBLBinding]' at dom/base/Element.cpp:588 Element.cpp:588: Assign(64,65, return := __temp_29**) Element.cpp:588: Call(65,66, binding.~__dt_comp ()) [[GC call]] Element.cpp:588: Call(66,67, principal.~__dt_comp ()) Element.cpp:588: Call(67,68, uri.~__dt_comp ()) Element.cpp:588: Call(68,69, style.~__dt_comp ()) Element.cpp:588: Call(69,70, obj.~__dt_comp ()) Element.cpp:589: [[end of function]] GC Function: _ZN6RefPtrI12nsXBLBindingED1Ev$RefPtr<T>::~RefPtr() [with T = nsXBLBinding] RefPtr<T>::~RefPtr() [with T = nsXBLBinding] [[base_dtor]] static void RefPtr<T>::ConstRemovingRefPtrTraits<U>::Release(U*) [with U = nsXBLBinding; T = nsXBLBinding] static void mozilla::RefPtrTraits<U>::Release(U*) [with U = nsXBLBinding] uint32 nsXBLBinding::Release() uint64 nsCycleCollectingAutoRefCnt::decr(void*, nsCycleCollectionParticipant*, uint8*) [with void (* suspect)(void*, nsCycleCollectionParticipant*, nsCycleCollectingAutoRefCnt*, bool*) = NS_CycleCollectorSuspect3; uintptr_t = long unsigned int] NS_CycleCollectorSuspect3 nsCycleCollector.cpp:void SuspectAfterShutdown(void*, nsCycleCollectionParticipant*, nsCycleCollectingAutoRefCnt*, uint8*) nsCycleCollectionParticipant.DeleteCycleCollectable void nsIContent::cycleCollection::DeleteCycleCollectable(void*) nsIContent.DeleteCycleCollectable unresolved nsIContent.DeleteCycleCollectable I don't think the analysis is right since the Rooted<> thing will go out of the scope after the RefPtr. MANUAL PUSH: Bustage fix for broken (I think) analysis
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -545,48 +545,50 @@ JSObject* Element::WrapObject(JSContext*
   if (!obj) {
     return nullptr;
   }
 
   if (!MayNeedToLoadXBLBinding(*this)) {
     return obj;
   }
 
-  RefPtr<ComputedStyle> style =
-      nsComputedDOMStyle::GetComputedStyleNoFlush(this, nullptr);
-  if (!style) {
-    return obj;
-  }
-
-  // We have a binding that must be installed.
-  const StyleUrlOrNone& computedBinding = style->StyleDisplay()->mBinding;
-  if (!computedBinding.IsUrl()) {
-    return obj;
-  }
-
-  auto& url = computedBinding.AsUrl();
-  nsCOMPtr<nsIURI> uri = url.GetURI();
-  nsCOMPtr<nsIPrincipal> principal = url.ExtraData().Principal();
-
-  nsXBLService* xblService = nsXBLService::GetInstance();
-  if (!xblService) {
-    dom::Throw(aCx, NS_ERROR_NOT_AVAILABLE);
-    return nullptr;
-  }
-
-  RefPtr<nsXBLBinding> binding;
-  xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding));
-
-  if (binding) {
-    if (nsContentUtils::IsSafeToRunScript()) {
-      binding->ExecuteAttachedHandler();
-    } else {
-      nsContentUtils::AddScriptRunner(
-          NewRunnableMethod("nsXBLBinding::ExecuteAttachedHandler", binding,
-                            &nsXBLBinding::ExecuteAttachedHandler));
+  {
+    RefPtr<ComputedStyle> style =
+        nsComputedDOMStyle::GetComputedStyleNoFlush(this, nullptr);
+    if (!style) {
+      return obj;
+    }
+
+    // We have a binding that must be installed.
+    const StyleUrlOrNone& computedBinding = style->StyleDisplay()->mBinding;
+    if (!computedBinding.IsUrl()) {
+      return obj;
+    }
+
+    auto& url = computedBinding.AsUrl();
+    nsCOMPtr<nsIURI> uri = url.GetURI();
+    nsCOMPtr<nsIPrincipal> principal = url.ExtraData().Principal();
+
+    nsXBLService* xblService = nsXBLService::GetInstance();
+    if (!xblService) {
+      dom::Throw(aCx, NS_ERROR_NOT_AVAILABLE);
+      return nullptr;
+    }
+
+    RefPtr<nsXBLBinding> binding;
+    xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding));
+
+    if (binding) {
+      if (nsContentUtils::IsSafeToRunScript()) {
+        binding->ExecuteAttachedHandler();
+      } else {
+        nsContentUtils::AddScriptRunner(
+            NewRunnableMethod("nsXBLBinding::ExecuteAttachedHandler", binding,
+                              &nsXBLBinding::ExecuteAttachedHandler));
+      }
     }
   }
 
   return obj;
 }
 
 /* virtual */
 nsINode* Element::GetScopeChainParent() const { return OwnerDoc(); }