Bug 1354200 - Exit instead of MOZ_CRASH on channel error in child process r=jld
authorJames Willcox <snorp@snorp.net>
Thu, 10 Jan 2019 22:45:44 +0000
changeset 510462 36802e2a349090305f53f7ef345bfe6a3f324243
parent 510461 653fa722ad95365d077f0392c86c5b418af1679f
child 510463 47b94d26f8a57c50298b284342f270151d273ed5
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1354200
milestone66.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 1354200 - Exit instead of MOZ_CRASH on channel error in child process r=jld Android mercilessly kills the parent in low memory situations, and we don't want that to trigger a crash when the child is abruptly disconnected. Differential Revision: https://phabricator.services.mozilla.com/D16234
ipc/glue/MessageChannel.cpp
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -5,16 +5,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ipc/MessageChannel.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/ipc/ProcessChild.h"
 #include "mozilla/ipc/ProtocolUtils.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Move.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
@@ -2519,17 +2520,26 @@ void MessageChannel::OnChannelErrorFromL
   IPC_LOG("OnChannelErrorFromLink");
 
   if (InterruptStackDepth() > 0) NotifyWorkerThread();
 
   if (AwaitingSyncReply() || AwaitingIncomingMessage()) NotifyWorkerThread();
 
   if (ChannelClosing != mChannelState) {
     if (mAbortOnError) {
-      MOZ_CRASH("Aborting on channel error.");
+      // mAbortOnError is set by main actors (e.g., ContentChild) to ensure
+      // that the process terminates even if normal shutdown is prevented.
+      // A MOZ_CRASH() here is not helpful because crash reporting relies
+      // on the parent process which we know is dead or otherwise unusable.
+      //
+      // Additionally, the parent process can (and often is) killed on Android
+      // when apps are backgrounded. We don't need to report a crash for
+      // normal behavior in that case.
+      printf_stderr("Exiting due to channel error.\n");
+      ProcessChild::QuickExit();
     }
     mChannelState = ChannelError;
     mMonitor->Notify();
   }
 
   PostErrorNotifyTask();
 }