From dc537cbc89b0507b88ba46fb82c4fc642b4b3187 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Mon, 3 Sep 2018 08:09:01 -1000 Subject: [PATCH] Bug 1488260 Part 2 - Cleanly shutdown when message forwarding fails, r=mccr8. --HG-- extra : rebase_source : ceb20246e2a6bc44e7141234f04f61d3ef74f381 --- toolkit/recordreplay/ipc/ParentForwarding.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/toolkit/recordreplay/ipc/ParentForwarding.cpp b/toolkit/recordreplay/ipc/ParentForwarding.cpp index 31b48a0cf640..43e1923d10a0 100644 --- a/toolkit/recordreplay/ipc/ParentForwarding.cpp +++ b/toolkit/recordreplay/ipc/ParentForwarding.cpp @@ -147,6 +147,15 @@ struct MOZ_RAII AutoMarkMainThreadWaitingForIPDLReply } }; +static void +BeginShutdown() +{ + // If there is a channel error or anything that could result from the child + // crashing, cleanly shutdown this process so that we don't generate a + // separate minidump which masks the initial failure. + MainThreadMessageLoop()->PostTask(NewRunnableFunction("Shutdown", Shutdown)); +} + class MiddlemanProtocol : public ipc::IToplevelProtocol { public: @@ -172,7 +181,8 @@ public: IPC::StringFromIPCMessageType(aMessage->type()), (int) aMessage->routing_id()); if (!aProtocol->GetIPCChannel()->Send(aMessage)) { - MOZ_CRASH("MiddlemanProtocol::ForwardMessageAsync"); + MOZ_RELEASE_ASSERT(aProtocol->mSide == ipc::ParentSide); + BeginShutdown(); } } else { delete aMessage; @@ -209,7 +219,8 @@ public: MOZ_RELEASE_ASSERT(!*aReply); Message* nReply = new Message(); if (!aProtocol->GetIPCChannel()->Send(aMessage, nReply)) { - MOZ_CRASH("MiddlemanProtocol::ForwardMessageSync"); + MOZ_RELEASE_ASSERT(aProtocol->mSide == ipc::ParentSide); + BeginShutdown(); } MonitorAutoLock lock(*gMonitor); @@ -245,7 +256,8 @@ public: MOZ_RELEASE_ASSERT(!*aReply); Message* nReply = new Message(); if (!aProtocol->GetIPCChannel()->Call(aMessage, nReply)) { - MOZ_CRASH("MiddlemanProtocol::ForwardCallMessage"); + MOZ_RELEASE_ASSERT(aProtocol->mSide == ipc::ParentSide); + BeginShutdown(); } MonitorAutoLock lock(*gMonitor); @@ -281,11 +293,11 @@ public: virtual void OnChannelClose() override { MOZ_RELEASE_ASSERT(mSide == ipc::ChildSide); - MainThreadMessageLoop()->PostTask(NewRunnableFunction("Shutdown", Shutdown)); + BeginShutdown(); } virtual void OnChannelError() override { - MainThreadMessageLoop()->PostTask(NewRunnableFunction("Shutdown", Shutdown)); + BeginShutdown(); } };