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
This commit is contained in:
Emilio Cobos Álvarez 2019-10-03 06:35:33 +02:00
parent 34fa4fa528
commit c863ef674b

View File

@ -550,38 +550,40 @@ JSObject* Element::WrapObject(JSContext* aCx,
return obj; return obj;
} }
RefPtr<ComputedStyle> style = {
nsComputedDOMStyle::GetComputedStyleNoFlush(this, nullptr); RefPtr<ComputedStyle> style =
if (!style) { nsComputedDOMStyle::GetComputedStyleNoFlush(this, nullptr);
return obj; if (!style) {
} return obj;
}
// We have a binding that must be installed. // We have a binding that must be installed.
const StyleUrlOrNone& computedBinding = style->StyleDisplay()->mBinding; const StyleUrlOrNone& computedBinding = style->StyleDisplay()->mBinding;
if (!computedBinding.IsUrl()) { if (!computedBinding.IsUrl()) {
return obj; return obj;
} }
auto& url = computedBinding.AsUrl(); auto& url = computedBinding.AsUrl();
nsCOMPtr<nsIURI> uri = url.GetURI(); nsCOMPtr<nsIURI> uri = url.GetURI();
nsCOMPtr<nsIPrincipal> principal = url.ExtraData().Principal(); nsCOMPtr<nsIPrincipal> principal = url.ExtraData().Principal();
nsXBLService* xblService = nsXBLService::GetInstance(); nsXBLService* xblService = nsXBLService::GetInstance();
if (!xblService) { if (!xblService) {
dom::Throw(aCx, NS_ERROR_NOT_AVAILABLE); dom::Throw(aCx, NS_ERROR_NOT_AVAILABLE);
return nullptr; return nullptr;
} }
RefPtr<nsXBLBinding> binding; RefPtr<nsXBLBinding> binding;
xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding)); xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding));
if (binding) { if (binding) {
if (nsContentUtils::IsSafeToRunScript()) { if (nsContentUtils::IsSafeToRunScript()) {
binding->ExecuteAttachedHandler(); binding->ExecuteAttachedHandler();
} else { } else {
nsContentUtils::AddScriptRunner( nsContentUtils::AddScriptRunner(
NewRunnableMethod("nsXBLBinding::ExecuteAttachedHandler", binding, NewRunnableMethod("nsXBLBinding::ExecuteAttachedHandler", binding,
&nsXBLBinding::ExecuteAttachedHandler)); &nsXBLBinding::ExecuteAttachedHandler));
}
} }
} }