Bug 1423261: Close the IPC channel during KillHard shutdowns to prevent shutdown crashes in the parent process. r=jimm
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Mon, 09 Apr 2018 15:54:52 -0400
changeset 779603 f45d6ae3fdb194a07ef5eba9f9a760f28f564b64
parent 779408 abb2fafe775b3e58cdff89164a229883755a08df
child 779604 4cd93e695965adeb76237e41d03c4a6d52ab27d1
push id105824
push usernnethercote@mozilla.com
push dateTue, 10 Apr 2018 09:55:33 +0000
reviewersjimm
bugs1423261
milestone61.0a1
Bug 1423261: Close the IPC channel during KillHard shutdowns to prevent shutdown crashes in the parent process. r=jimm
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -3185,27 +3185,36 @@ ContentParent::KillHard(const char* aRea
       NS_LITERAL_CSTRING("ipc_channel_error"),
       reason);
 
     Telemetry::Accumulate(Telemetry::SUBPROCESS_KILL_HARD, reason, 1);
 
     RefPtr<ContentParent> self = this;
     std::function<void(bool)> callback = [self](bool aResult) {
       self->OnGenerateMinidumpComplete(aResult);
+      MessageChannel* channel = self->GetIPCChannel();
+      if (channel) {
+        channel->Close();
+      }
     };
     // Generate the report and insert into the queue for submittal.
     mCrashReporter->GenerateMinidumpAndPair(Process(),
                                             nullptr,
                                             NS_LITERAL_CSTRING("browser"),
                                             Move(callback),
                                             true);
     return;
   }
 
   OnGenerateMinidumpComplete(false);
+
+  MessageChannel* channel = GetIPCChannel();
+  if (channel) {
+    channel->Close();
+  }
 }
 
 void
 ContentParent::OnGenerateMinidumpComplete(bool aDumpResult)
 {
   if (mCrashReporter && aDumpResult) {
     // CrashReporterHost::GenerateMinidumpAndPair() is successful.
     mCreatedPairedMinidumps = mCrashReporter->FinalizeCrashReport();