Bug 1258312 - Add crash annotation to EnumSerializer. r=jld, a=ritu
authorKan-Ru Chen <kanru@kanru.info>
Wed, 30 Mar 2016 12:32:26 +0800
changeset 310575 f33dbaaf6abd2af0dd3a917c880e759aca2a5c12
parent 310574 be11a112d7e9238394d0a6ab4c74c7b81433a9ce
child 310576 e4d417a8b34cc19ca33b030aa8eafb32a98d3bb7
push id9408
push usercbook@mozilla.com
push dateThu, 14 Apr 2016 10:33:50 +0000
treeherdermozilla-aurora@f33dbaaf6abd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld, ritu
bugs1258312
milestone47.0a2
Bug 1258312 - Add crash annotation to EnumSerializer. r=jld, a=ritu 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,