Bug 1354200 - Exit instead of MOZ_CRASH on channel error in child process. r=jld, a=jcristau GECKOVIEW_64_RELBRANCH
authorJames Willcox <snorp@snorp.net>
Thu, 10 Jan 2019 22:45:44 +0000
changeset 501503 f9045f8090c7
parent 501502 9c744599570f
child 501505 ba87e21ad6f1
push id1902
push userjcristau@mozilla.com
push dateFri, 11 Jan 2019 13:42:33 +0000
treeherdermozilla-release@f9045f8090c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld, jcristau
Bug 1354200 - Exit instead of MOZ_CRASH on channel error in child process. r=jld, a=jcristau 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
--- 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"
@@ -2661,17 +2662,26 @@ MessageChannel::OnChannelErrorFromLink()
     if (InterruptStackDepth() > 0)
     if (AwaitingSyncReply() || AwaitingIncomingMessage())
     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;