From 55cad8d48f52f06d8f7855c911f1ccacd37eaffd Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Fri, 8 Dec 2023 15:56:39 +0000 Subject: [PATCH] Bug 1847298: IPC constructor cleanup r=nika,padenot,dom-storage-reviewers,necko-reviewers,cookie-reviewers,asuth,Jamie Differential Revision: https://phabricator.services.mozilla.com/D185472 --- accessible/generic/DocAccessible.cpp | 13 ++++--------- accessible/generic/DocAccessible.h | 1 + dom/base/nsContentPermissionHelper.cpp | 10 ++++++---- dom/broadcastchannel/BroadcastChannel.cpp | 7 +++++-- dom/file/FileCreatorHelper.cpp | 4 ++++ dom/indexedDB/IDBDatabase.cpp | 10 +++++++--- dom/ipc/BrowserChild.cpp | 3 --- dom/ipc/BrowserChild.h | 13 ------------- dom/media/ipc/MFCDMChild.cpp | 2 +- dom/media/ipc/RemoteAudioDecoder.cpp | 4 ++-- dom/media/ipc/RemoteVideoDecoder.cpp | 4 ++-- .../BenchmarkStorageChild.cpp | 4 +++- dom/media/systemservices/CamerasChild.cpp | 18 +++++++----------- .../webspeech/synth/nsSynthVoiceRegistry.cpp | 7 ++++--- dom/payments/PaymentRequestManager.cpp | 5 ++++- dom/serviceworkers/FetchEventOpProxyParent.cpp | 2 +- dom/storage/LocalStorageManager.cpp | 4 ++++ extensions/spellcheck/src/mozSpellChecker.cpp | 5 ++++- ipc/glue/IdleSchedulerChild.cpp | 4 +++- netwerk/cookie/CookieServiceChild.cpp | 14 +++++++------- netwerk/cookie/CookieServiceChild.h | 2 ++ netwerk/dns/DNSRequestChild.cpp | 6 +++--- netwerk/protocol/gio/GIOChannelChild.cpp | 8 +++++--- netwerk/protocol/http/nsHttpChannel.cpp | 9 ++++++--- netwerk/protocol/http/nsHttpHandler.cpp | 2 +- .../websocket/WebSocketChannelChild.cpp | 6 ++++-- 26 files changed, 90 insertions(+), 77 deletions(-) diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index 4d368ad5c9c1..863df413510f 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -1601,17 +1601,12 @@ void DocAccessible::DoInitialUpdate() { // RootAccessibles. MOZ_ASSERT(IsRoot()); DocAccessibleChild* ipcDoc = IPCDoc(); - if (ipcDoc) { - browserChild->SetTopLevelDocAccessibleChild(ipcDoc); - } else { + if (!ipcDoc) { ipcDoc = new DocAccessibleChild(this, browserChild); + MOZ_RELEASE_ASSERT(browserChild->SendPDocAccessibleConstructor( + ipcDoc, nullptr, 0, mDocumentNode->GetBrowsingContext())); + // trying to recover from this failing is problematic SetIPCDoc(ipcDoc); - // Subsequent initialization might depend on being able to get the - // top level DocAccessibleChild, so set that as early as possible. - browserChild->SetTopLevelDocAccessibleChild(ipcDoc); - - browserChild->SendPDocAccessibleConstructor( - ipcDoc, nullptr, 0, mDocumentNode->GetBrowsingContext()); } } } diff --git a/accessible/generic/DocAccessible.h b/accessible/generic/DocAccessible.h index 2ef6f04e4a3a..fa1ead88b571 100644 --- a/accessible/generic/DocAccessible.h +++ b/accessible/generic/DocAccessible.h @@ -782,6 +782,7 @@ class DocAccessible : public HyperTextAccessible, PresShell* mPresShell; // Exclusively owned by IPDL so don't manually delete it! + // Cleared in ActorDestroy DocAccessibleChild* mIPCDoc; // These data structures map between LocalAccessibles and CacheDomains, diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index 9decb906a59d..0e1668ec5e3f 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -293,10 +293,12 @@ nsresult nsContentPermissionUtils::AskPermission( NS_ENSURE_SUCCESS(rv, rv); req->IPDLAddRef(); - ContentChild::GetSingleton()->SendPContentPermissionRequestConstructor( - req, permArray, principal, topLevelPrincipal, - hasValidTransientUserGestureActivation, - isRequestDelegatedToUnsafeThirdParty, child->GetTabId()); + if (!ContentChild::GetSingleton()->SendPContentPermissionRequestConstructor( + req, permArray, principal, topLevelPrincipal, + hasValidTransientUserGestureActivation, + isRequestDelegatedToUnsafeThirdParty, child->GetTabId())) { + return NS_ERROR_FAILURE; + } ContentPermissionRequestChildMap()[req.get()] = child->GetTabId(); req->Sendprompt(); diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp index a52f3a29eb7e..aee657fef7dd 100644 --- a/dom/broadcastchannel/BroadcastChannel.cpp +++ b/dom/broadcastchannel/BroadcastChannel.cpp @@ -255,10 +255,13 @@ already_AddRefed BroadcastChannel::Constructor( PBroadcastChannelChild* actor = actorChild->SendPBroadcastChannelConstructor( storagePrincipalInfo, origin, nsString(aChannel)); + if (!actor) { + // The PBackground actor is shutting down, return a 'generic' error. + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } bc->mActor = static_cast(actor); - MOZ_ASSERT(bc->mActor); - bc->mActor->SetParent(bc); bc->mOriginForEvents = std::move(originForEvents); diff --git a/dom/file/FileCreatorHelper.cpp b/dom/file/FileCreatorHelper.cpp index 2c4ee4c04183..fcd72ca35132 100644 --- a/dom/file/FileCreatorHelper.cpp +++ b/dom/file/FileCreatorHelper.cpp @@ -59,6 +59,10 @@ already_AddRefed FileCreatorHelper::CreateFile( PFileCreatorChild* actor = actorChild->SendPFileCreatorConstructor( path, aBag.mType, aBag.mName, lastModified, aBag.mExistenceCheck, aIsFromNsIFile); + if (!actor) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } static_cast(actor)->SetPromise(promise); return promise.forget(); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 455ea2bb6951..69565245d19c 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -609,7 +609,7 @@ RefPtr IDBDatabase::Transaction( return nullptr; } - BackgroundTransactionChild* actor = + RefPtr actor = new BackgroundTransactionChild(transaction.clonePtr()); IDB_LOG_MARK_CHILD_TRANSACTION( @@ -617,8 +617,12 @@ RefPtr IDBDatabase::Transaction( transaction->LoggingSerialNumber(), IDB_LOG_STRINGIFY(this), IDB_LOG_STRINGIFY(*transaction)); - MOZ_ALWAYS_TRUE(mBackgroundActor->SendPBackgroundIDBTransactionConstructor( - actor, sortedStoreNames, mode)); + if (!mBackgroundActor->SendPBackgroundIDBTransactionConstructor( + actor, sortedStoreNames, mode)) { + IDB_REPORT_INTERNAL_ERR(); + aRv.ThrowUnknownError("Failed to create IndexedDB transaction"); + return nullptr; + } transaction->SetBackgroundActor(actor); diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 1b2d442b8836..a2681f8a397b 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -291,9 +291,6 @@ BrowserChild::BrowserChild(ContentChild* aManager, const TabId& aTabId, mIsPreservingLayers(false), #if defined(XP_WIN) && defined(ACCESSIBILITY) mNativeWindowHandle(0), -#endif -#if defined(ACCESSIBILITY) - mTopLevelDocAccessibleChild(nullptr), #endif mCancelContentJSEpoch(0) { mozilla::HoldJSObjects(this); diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index 3bdca55b8a0d..bb61347582c9 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -583,16 +583,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, BrowsingContext* GetBrowsingContext() const { return mBrowsingContext; } -#if defined(ACCESSIBILITY) - void SetTopLevelDocAccessibleChild(PDocAccessibleChild* aTopLevelChild) { - mTopLevelDocAccessibleChild = aTopLevelChild; - } - - PDocAccessibleChild* GetTopLevelDocAccessibleChild() { - return mTopLevelDocAccessibleChild; - } -#endif - // The transform from the coordinate space of this BrowserChild to the // coordinate space of the native window its BrowserParent is in. mozilla::LayoutDeviceToLayoutDeviceMatrix4x4 @@ -839,9 +829,6 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, uintptr_t mNativeWindowHandle; #endif // defined(XP_WIN) -#if defined(ACCESSIBILITY) - PDocAccessibleChild* mTopLevelDocAccessibleChild; -#endif int32_t mCancelContentJSEpoch; Maybe mChildToParentConversionMatrix; diff --git a/dom/media/ipc/MFCDMChild.cpp b/dom/media/ipc/MFCDMChild.cpp index bccb9c1acd60..de25bc594a94 100644 --- a/dom/media/ipc/MFCDMChild.cpp +++ b/dom/media/ipc/MFCDMChild.cpp @@ -103,7 +103,7 @@ RefPtr MFCDMChild::EnsureRemote() { } mIPDLSelfRef = this; - Unused << manager->SendPMFCDMConstructor(this, mKeySystem); + MOZ_ALWAYS_TRUE(manager->SendPMFCDMConstructor(this, mKeySystem)); mState = NS_OK; mRemotePromiseHolder.ResolveIfExists(true, __func__); }, diff --git a/dom/media/ipc/RemoteAudioDecoder.cpp b/dom/media/ipc/RemoteAudioDecoder.cpp index 09b420261fc3..4622410fad3d 100644 --- a/dom/media/ipc/RemoteAudioDecoder.cpp +++ b/dom/media/ipc/RemoteAudioDecoder.cpp @@ -56,8 +56,8 @@ MediaResult RemoteAudioDecoderChild::InitIPDL( } mIPDLSelfRef = this; - Unused << manager->SendPRemoteDecoderConstructor( - this, aAudioInfo, aOptions, Nothing(), aMediaEngineId, Nothing()); + MOZ_ALWAYS_TRUE(manager->SendPRemoteDecoderConstructor( + this, aAudioInfo, aOptions, Nothing(), aMediaEngineId, Nothing())); return NS_OK; } diff --git a/dom/media/ipc/RemoteVideoDecoder.cpp b/dom/media/ipc/RemoteVideoDecoder.cpp index 991bcac40b93..830203d92295 100644 --- a/dom/media/ipc/RemoteVideoDecoder.cpp +++ b/dom/media/ipc/RemoteVideoDecoder.cpp @@ -124,8 +124,8 @@ MediaResult RemoteVideoDecoderChild::InitIPDL( mIPDLSelfRef = this; VideoDecoderInfoIPDL decoderInfo(aVideoInfo, aFramerate); - Unused << manager->SendPRemoteDecoderConstructor( - this, decoderInfo, aOptions, aIdentifier, aMediaEngineId, aTrackingId); + MOZ_ALWAYS_TRUE(manager->SendPRemoteDecoderConstructor( + this, decoderInfo, aOptions, aIdentifier, aMediaEngineId, aTrackingId)); return NS_OK; } diff --git a/dom/media/mediacapabilities/BenchmarkStorageChild.cpp b/dom/media/mediacapabilities/BenchmarkStorageChild.cpp index 9482f5bffe5c..32bf9adac210 100644 --- a/dom/media/mediacapabilities/BenchmarkStorageChild.cpp +++ b/dom/media/mediacapabilities/BenchmarkStorageChild.cpp @@ -18,7 +18,9 @@ PBenchmarkStorageChild* BenchmarkStorageChild::Instance() { sChild = new BenchmarkStorageChild(); PContentChild* contentChild = dom::ContentChild::GetSingleton(); MOZ_ASSERT(contentChild); - contentChild->SendPBenchmarkStorageConstructor(); + if (!contentChild->SendPBenchmarkStorageConstructor()) { + MOZ_CRASH("SendPBenchmarkStorageConstructor failed"); + } } MOZ_ASSERT(sChild); return sChild; diff --git a/dom/media/systemservices/CamerasChild.cpp b/dom/media/systemservices/CamerasChild.cpp index 731a98a37b60..c7369aad3602 100644 --- a/dom/media/systemservices/CamerasChild.cpp +++ b/dom/media/systemservices/CamerasChild.cpp @@ -41,25 +41,21 @@ class InitializeIPCThread : public Runnable { : Runnable("camera::InitializeIPCThread"), mCamerasChild(nullptr) {} NS_IMETHOD Run() override { - // Try to get the PBackground handle + // Get the PBackground handle ipc::PBackgroundChild* existingBackgroundChild = - ipc::BackgroundChild::GetForCurrentThread(); - // If it's not spun up yet, block until it is, and retry + ipc::BackgroundChild::GetOrCreateForCurrentThread(); + LOG(("BackgroundChild: %p", existingBackgroundChild)); if (!existingBackgroundChild) { - LOG(("No existingBackgroundChild")); - existingBackgroundChild = - ipc::BackgroundChild::GetOrCreateForCurrentThread(); - LOG(("BackgroundChild: %p", existingBackgroundChild)); - if (!existingBackgroundChild) { - return NS_ERROR_FAILURE; - } + return NS_ERROR_FAILURE; } // Create CamerasChild // We will be returning the resulting pointer (synchronously) to our caller. mCamerasChild = static_cast( existingBackgroundChild->SendPCamerasConstructor()); - + if (!mCamerasChild) { + return NS_ERROR_FAILURE; + } return NS_OK; } diff --git a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp index c4781661f3bc..e2f60cbc6699 100644 --- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp +++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp @@ -146,9 +146,10 @@ NS_IMPL_ISUPPORTS(nsSynthVoiceRegistry, nsISynthVoiceRegistry) nsSynthVoiceRegistry::nsSynthVoiceRegistry() : mSpeechSynthChild(nullptr), mUseGlobalQueue(false), mIsSpeaking(false) { if (XRE_IsContentProcess()) { - mSpeechSynthChild = new SpeechSynthesisChild(); - ContentChild::GetSingleton()->SendPSpeechSynthesisConstructor( - mSpeechSynthChild); + SpeechSynthesisChild* actor = new SpeechSynthesisChild(); + if (ContentChild::GetSingleton()->SendPSpeechSynthesisConstructor(actor)) { + mSpeechSynthChild = actor; + } } } diff --git a/dom/payments/PaymentRequestManager.cpp b/dom/payments/PaymentRequestManager.cpp index f615fedf77df..32ccac145a59 100644 --- a/dom/payments/PaymentRequestManager.cpp +++ b/dom/payments/PaymentRequestManager.cpp @@ -360,7 +360,10 @@ PaymentRequestChild* PaymentRequestManager::GetPaymentChild( aRequest->GetInternalId(requestId); PaymentRequestChild* paymentChild = new PaymentRequestChild(aRequest); - browserChild->SendPPaymentRequestConstructor(paymentChild); + if (!browserChild->SendPPaymentRequestConstructor(paymentChild)) { + // deleted by Constructor + return nullptr; + } return paymentChild; } diff --git a/dom/serviceworkers/FetchEventOpProxyParent.cpp b/dom/serviceworkers/FetchEventOpProxyParent.cpp index 9a67b4239c85..a8c4488a2683 100644 --- a/dom/serviceworkers/FetchEventOpProxyParent.cpp +++ b/dom/serviceworkers/FetchEventOpProxyParent.cpp @@ -133,7 +133,7 @@ ParentToParentFetchEventRespondWithResult ToParentToParent( copyArgs.preloadResponseEndArgs() = aArgs.preloadResponseEndArgs(); } - FetchEventOpProxyParent* actor = + RefPtr actor = new FetchEventOpProxyParent(std::move(aReal), std::move(aPromise)); // As long as the fetch event was pending, the FetchEventOpParent was diff --git a/dom/storage/LocalStorageManager.cpp b/dom/storage/LocalStorageManager.cpp index 58b57df76a64..51ff3e4d0cec 100644 --- a/dom/storage/LocalStorageManager.cpp +++ b/dom/storage/LocalStorageManager.cpp @@ -212,6 +212,10 @@ nsresult LocalStorageManager::GetStorageInternal( if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } + + if (!backgroundActor->CanSend()) { + return NS_ERROR_FAILURE; + } #endif // There is always a single instance of a cache per scope diff --git a/extensions/spellcheck/src/mozSpellChecker.cpp b/extensions/spellcheck/src/mozSpellChecker.cpp index d5b0537bfe71..3fc600adbbab 100644 --- a/extensions/spellcheck/src/mozSpellChecker.cpp +++ b/extensions/spellcheck/src/mozSpellChecker.cpp @@ -53,8 +53,11 @@ nsresult mozSpellChecker::Init() { mozilla::dom::ContentChild* contentChild = mozilla::dom::ContentChild::GetSingleton(); MOZ_ASSERT(contentChild); + // mEngine is nulled in RemoteSpellcheckEngineChild(), so we don't need to + // worry about SendPRemoveSpellcheckEngineConstructor failing mEngine = new RemoteSpellcheckEngineChild(this); - contentChild->SendPRemoteSpellcheckEngineConstructor(mEngine); + MOZ_ALWAYS_TRUE( + contentChild->SendPRemoteSpellcheckEngineConstructor(mEngine)); } else { mPersonalDictionary = do_GetService("@mozilla.org/spellchecker/personaldictionary;1"); diff --git a/ipc/glue/IdleSchedulerChild.cpp b/ipc/glue/IdleSchedulerChild.cpp index 0a6396856397..31cfb5457dfb 100644 --- a/ipc/glue/IdleSchedulerChild.cpp +++ b/ipc/glue/IdleSchedulerChild.cpp @@ -140,8 +140,10 @@ IdleSchedulerChild* IdleSchedulerChild::GetMainThreadIdleScheduler() { ipc::PBackgroundChild* background = ipc::BackgroundChild::GetOrCreateForCurrentThread(); if (background) { + // this is nulled out on our destruction, so we don't need to worry sMainThreadIdleScheduler = new ipc::IdleSchedulerChild(); - background->SendPIdleSchedulerConstructor(sMainThreadIdleScheduler); + MOZ_ALWAYS_TRUE( + background->SendPIdleSchedulerConstructor(sMainThreadIdleScheduler)); } return sMainThreadIdleScheduler; } diff --git a/netwerk/cookie/CookieServiceChild.cpp b/netwerk/cookie/CookieServiceChild.cpp index 69f8e02686b3..94c485895a79 100644 --- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -47,6 +47,7 @@ static StaticRefPtr gCookieChildService; already_AddRefed CookieServiceChild::GetSingleton() { if (!gCookieChildService) { gCookieChildService = new CookieServiceChild(); + gCookieChildService->Init(); ClearOnShutdown(&gCookieChildService); } @@ -56,9 +57,11 @@ already_AddRefed CookieServiceChild::GetSingleton() { NS_IMPL_ISUPPORTS(CookieServiceChild, nsICookieService, nsISupportsWeakReference) -CookieServiceChild::CookieServiceChild() { - NS_ASSERTION(IsNeckoChild(), "not a child process"); +CookieServiceChild::CookieServiceChild() { NeckoChild::InitNeckoChild(); } +CookieServiceChild::~CookieServiceChild() { gCookieChildService = nullptr; } + +void CookieServiceChild::Init() { auto* cc = static_cast(gNeckoChild->Manager()); if (cc->IsShuttingDown()) { return; @@ -67,9 +70,8 @@ CookieServiceChild::CookieServiceChild() { // This corresponds to Release() in DeallocPCookieService. NS_ADDREF_THIS(); - NeckoChild::InitNeckoChild(); - - // Create a child PCookieService actor. + // Create a child PCookieService actor. Don't do this in the constructor + // since it could release 'this' on failure gNeckoChild->SendPCookieServiceConstructor(this); mThirdPartyUtil = ThirdPartyUtil::GetInstance(); @@ -79,8 +81,6 @@ CookieServiceChild::CookieServiceChild() { NS_ASSERTION(mTLDService, "couldn't get TLDService"); } -CookieServiceChild::~CookieServiceChild() { gCookieChildService = nullptr; } - void CookieServiceChild::TrackCookieLoad(nsIChannel* aChannel) { if (!CanSend()) { return; diff --git a/netwerk/cookie/CookieServiceChild.h b/netwerk/cookie/CookieServiceChild.h index 0b07dbea1521..37c62d4a4c2c 100644 --- a/netwerk/cookie/CookieServiceChild.h +++ b/netwerk/cookie/CookieServiceChild.h @@ -37,6 +37,8 @@ class CookieServiceChild final : public PCookieServiceChild, CookieServiceChild(); + void Init(); + static already_AddRefed GetSingleton(); void TrackCookieLoad(nsIChannel* aChannel); diff --git a/netwerk/dns/DNSRequestChild.cpp b/netwerk/dns/DNSRequestChild.cpp index 578895186a1f..204fa810a11e 100644 --- a/netwerk/dns/DNSRequestChild.cpp +++ b/netwerk/dns/DNSRequestChild.cpp @@ -428,7 +428,7 @@ void DNSRequestSender::StartRequest() { return; } - if (DNSRequestChild* child = mIPCActor->AsDNSRequestChild()) { + if (RefPtr child = mIPCActor->AsDNSRequestChild()) { if (XRE_IsContentProcess()) { mozilla::dom::ContentChild* cc = static_cast(gNeckoChild->Manager()); @@ -450,8 +450,8 @@ void DNSRequestSender::StartRequest() { return; } - socketProcessChild->SendPDNSRequestConstructor( - child, mHost, mTrrServer, mPort, mType, mOriginAttributes, mFlags); + MOZ_ALWAYS_TRUE(socketProcessChild->SendPDNSRequestConstructor( + child, mHost, mTrrServer, mPort, mType, mOriginAttributes, mFlags)); } else { MOZ_ASSERT(false, "Wrong process"); return; diff --git a/netwerk/protocol/gio/GIOChannelChild.cpp b/netwerk/protocol/gio/GIOChannelChild.cpp index 9f8d19ce1e14..2adb611666a0 100644 --- a/netwerk/protocol/gio/GIOChannelChild.cpp +++ b/netwerk/protocol/gio/GIOChannelChild.cpp @@ -123,13 +123,15 @@ GIOChannelChild::AsyncOpen(nsIStreamListener* aListener) { // This must happen before the constructor message is sent. SetupNeckoTarget(); - gNeckoChild->SendPGIOChannelConstructor( - this, browserChild, IPC::SerializedLoadContext(this), openArgs); - // The socket transport layer in the chrome process now has a logical ref to // us until OnStopRequest is called. AddIPDLReference(); + if (!gNeckoChild->SendPGIOChannelConstructor( + this, browserChild, IPC::SerializedLoadContext(this), openArgs)) { + return NS_ERROR_FAILURE; + } + mIsPending = true; mWasOpened = true; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index ef2b06f45cdc..f0ac7e57b380 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -1374,6 +1374,10 @@ nsresult nsHttpChannel::SetupTransaction() { if (NS_WARN_IF(!gIOService->SocketProcessReady())) { return NS_ERROR_NOT_AVAILABLE; } + SocketProcessParent* socketProcess = SocketProcessParent::GetSingleton(); + if (!socketProcess->CanSend()) { + return NS_ERROR_NOT_AVAILABLE; + } nsCOMPtr parentChannel; NS_QueryNotificationCallbacks(this, parentChannel); @@ -1395,11 +1399,10 @@ nsresult nsHttpChannel::SetupTransaction() { transParent->SetRedirectTimestamp(mRedirectStartTimeStamp, mRedirectEndTimeStamp); - SocketProcessParent* socketProcess = SocketProcessParent::GetSingleton(); if (socketProcess) { - Unused << socketProcess->SendPHttpTransactionConstructor(transParent); + MOZ_ALWAYS_TRUE( + socketProcess->SendPHttpTransactionConstructor(transParent)); } - mTransaction = transParent; } else { mTransaction = new nsHttpTransaction(); diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 39eaa857c76e..ba116ff4a803 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -514,7 +514,7 @@ nsresult nsHttpHandler::InitConnectionMgr() { mConnMgr = new HttpConnectionMgrParent(); RefPtr self = this; auto task = [self]() { - HttpConnectionMgrParent* parent = + RefPtr parent = self->mConnMgr->AsHttpConnectionMgrParent(); Unused << SocketProcessParent::GetSingleton() ->SendPHttpConnectionMgrConstructor( diff --git a/netwerk/protocol/websocket/WebSocketChannelChild.cpp b/netwerk/protocol/websocket/WebSocketChannelChild.cpp index 5586035d7dec..2931b4706551 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp @@ -514,8 +514,10 @@ WebSocketChannelChild::AsyncOpenNative( // This must be called before sending constructor message. SetupNeckoTarget(); - gNeckoChild->SendPWebSocketConstructor( - this, browserChild, IPC::SerializedLoadContext(this), mSerial); + if (!gNeckoChild->SendPWebSocketConstructor( + this, browserChild, IPC::SerializedLoadContext(this), mSerial)) { + return NS_ERROR_UNEXPECTED; + } if (!SendAsyncOpen(uri, aOrigin, aOriginAttributes, aInnerWindowID, mProtocol, mEncrypted, mPingInterval, mClientSetPingInterval, mPingResponseTimeout, mClientSetPingTimeout, loadInfoArgs,