Bug 1102052 - Crash for PBackground protocol errors, r=mrbkap, a=lsblakk.
authorBen Turner <bent.mozilla@gmail.com>
Thu, 20 Nov 2014 11:48:18 -0800
changeset 234021 56f4563592530f85bc870968a304afe538fe0c2f
parent 234020 3c5899276eed10c92b0f4b7e0841f2f71850df97
child 234022 c1ba711083666643eaa5118bb6c45aa2e38fb038
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, lsblakk
bugs1102052
milestone35.0a2
Bug 1102052 - Crash for PBackground protocol errors, r=mrbkap, a=lsblakk.
ipc/glue/BackgroundChildImpl.cpp
ipc/glue/BackgroundChildImpl.h
--- a/ipc/glue/BackgroundChildImpl.cpp
+++ b/ipc/glue/BackgroundChildImpl.cpp
@@ -1,15 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "BackgroundChildImpl.h"
 
 #include "FileDescriptorSetChild.h"
+#include "mozilla/Assertions.h"
 #include "mozilla/dom/PBlobChild.h"
 #include "mozilla/dom/indexedDB/PBackgroundIDBFactoryChild.h"
 #include "mozilla/dom/ipc/BlobChild.h"
 #include "mozilla/ipc/PBackgroundTestChild.h"
 #include "nsTraceRefcnt.h"
 
 namespace {
 
@@ -76,16 +77,49 @@ BackgroundChildImpl::BackgroundChildImpl
 
 BackgroundChildImpl::~BackgroundChildImpl()
 {
   // May happen on any thread!
   MOZ_COUNT_DTOR(mozilla::ipc::BackgroundChildImpl);
 }
 
 void
+BackgroundChildImpl::ProcessingError(Result aWhat)
+{
+  // May happen on any thread!
+
+  nsAutoCString abortMessage;
+
+  switch (aWhat) {
+
+#define HANDLE_CASE(_result)                                                   \
+    case _result:                                                              \
+      abortMessage.AssignLiteral(#_result);                                    \
+      break
+
+    HANDLE_CASE(MsgDropped);
+    HANDLE_CASE(MsgNotKnown);
+    HANDLE_CASE(MsgNotAllowed);
+    HANDLE_CASE(MsgPayloadError);
+    HANDLE_CASE(MsgProcessingError);
+    HANDLE_CASE(MsgRouteError);
+    HANDLE_CASE(MsgValueError);
+
+#undef HANDLE_CASE
+
+    default:
+      MOZ_CRASH("Unknown error code!");
+  }
+
+  // This is just MOZ_CRASH() un-inlined so that we can pass the result code as
+  // a string. MOZ_CRASH() only supports string literals at the moment.
+  MOZ_ReportCrash(abortMessage.get(), __FILE__, __LINE__); MOZ_REALLY_CRASH();
+}
+
+void
 BackgroundChildImpl::ActorDestroy(ActorDestroyReason aWhy)
 {
   // May happen on any thread!
 }
 
 PBackgroundTestChild*
 BackgroundChildImpl::AllocPBackgroundTestChild(const nsCString& aTestArg)
 {
--- a/ipc/glue/BackgroundChildImpl.h
+++ b/ipc/glue/BackgroundChildImpl.h
@@ -36,16 +36,19 @@ public:
   static ThreadLocal*
   GetThreadLocalForCurrentThread();
 
 protected:
   BackgroundChildImpl();
   virtual ~BackgroundChildImpl();
 
   virtual void
+  ProcessingError(Result aWhat) MOZ_OVERRIDE;
+
+  virtual void
   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
 
   virtual PBackgroundTestChild*
   AllocPBackgroundTestChild(const nsCString& aTestArg) MOZ_OVERRIDE;
 
   virtual bool
   DeallocPBackgroundTestChild(PBackgroundTestChild* aActor) MOZ_OVERRIDE;