Bug 1258312 - Add crash annotation to EnumSerializer r=jld
authorKan-Ru Chen <kanru@kanru.info>
Wed, 30 Mar 2016 12:32:26 +0800
changeset 291916 9f0609cb275d1a0bb2916886e3f5b4c3644d9837
parent 291915 17030bff31b48f7cf992f7164d5f9769ba0fa4ef
child 291917 b0b19497c80c49c7f3fe259faf052fde16acf80c
push id30149
push usercbook@mozilla.com
push dateThu, 07 Apr 2016 09:52:31 +0000
treeherdermozilla-central@b6683e141c47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1258312
milestone48.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 1258312 - Add crash annotation to EnumSerializer r=jld MozReview-Commit-ID: DShQTzeFGQc
ipc/glue/IPCMessageUtils.h
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -20,16 +20,19 @@
 #ifdef XP_WIN
 #include "mozilla/TimeStamp_windows.h"
 #endif
 #include "mozilla/TypeTraits.h"
 #include "mozilla/IntegerTypeTraits.h"
 
 #include <stdint.h>
 
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
 #include "nsID.h"
 #include "nsIWidget.h"
 #include "nsMemory.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "js/StructuredClone.h"
 #include "nsCSSProperty.h"
 
@@ -108,18 +111,27 @@ struct EnumSerializer {
 
   static void Write(Message* aMsg, const paramType& aValue) {
     MOZ_ASSERT(EnumValidator::IsLegalValue(aValue));
     WriteParam(aMsg, uintParamType(aValue));
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult) {
     uintParamType value;
-    if(!ReadParam(aMsg, aIter, &value) ||
-       !EnumValidator::IsLegalValue(paramType(value))) {
+    if (!ReadParam(aMsg, aIter, &value)) {
+#ifdef MOZ_CRASHREPORTER
+      CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"),
+                                         NS_LITERAL_CSTRING("Bad iter"));
+#endif
+      return false;
+    } else if (!EnumValidator::IsLegalValue(paramType(value))) {
+#ifdef MOZ_CRASHREPORTER
+      CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"),
+                                         NS_LITERAL_CSTRING("Illegal value"));
+#endif
       return false;
     }
     *aResult = paramType(value);
     return true;
   }
 };
 
 template <typename E,