Bug 1240651 - Annotate addonId into crash report (r=bholley)
authorYoshi Huang <allstars.chh@mozilla.com>
Fri, 29 Jan 2016 15:19:56 -0800
changeset 282640 62600c1a0dcbabcf17ac16b63e2199b502eafa08
parent 282639 de7e091bbcdf4ce19ccc85f66a977adeecbd30e2
child 282641 2e3bde77f6d2a01b99992bbae699400fba96967a
push id29968
push usercbook@mozilla.com
push dateTue, 02 Feb 2016 10:51:21 +0000
treeherdermozilla-central@5f9ba76eb3b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1240651
milestone47.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 1240651 - Annotate addonId into crash report (r=bholley)
caps/BasePrincipal.cpp
caps/moz.build
caps/nsScriptSecurityManager.cpp
--- a/caps/BasePrincipal.cpp
+++ b/caps/BasePrincipal.cpp
@@ -2,16 +2,19 @@
 /* vim: set ts=2 sw=2 et tw=80: */
 /* 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 "mozilla/BasePrincipal.h"
 
 #include "nsDocShell.h"
+#ifdef MOZ_CRASHREPORTER
+#include "nsExceptionHandler.h"
+#endif
 #include "nsIAddonPolicyService.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 
 #include "nsPrincipal.h"
 #include "nsNetUtil.h"
 #include "nsIURIWithPrincipal.h"
@@ -116,17 +119,23 @@ OriginAttributes::CreateSuffix(nsACStrin
     params->Set(NS_LITERAL_STRING("appId"), value);
   }
 
   if (mInBrowser) {
     params->Set(NS_LITERAL_STRING("inBrowser"), NS_LITERAL_STRING("1"));
   }
 
   if (!mAddonId.IsEmpty()) {
-    MOZ_RELEASE_ASSERT(mAddonId.FindCharInSet(dom::quota::QuotaManager::kReplaceChars) == kNotFound);
+    if (mAddonId.FindCharInSet(dom::quota::QuotaManager::kReplaceChars) != kNotFound) {
+#ifdef MOZ_CRASHREPORTER
+      CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Crash_AddonId"),
+                                         NS_ConvertUTF16toUTF8(mAddonId));
+#endif
+      MOZ_CRASH();
+    }
     params->Set(NS_LITERAL_STRING("addonId"), mAddonId);
   }
 
   if (mUserContextId != nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) {
     value.Truncate();
     value.AppendInt(mUserContextId);
     params->Set(NS_LITERAL_STRING("userContextId"), value);
   }
--- a/caps/moz.build
+++ b/caps/moz.build
@@ -27,18 +27,23 @@ EXPORTS += [
     'nsNullPrincipal.h',
     'nsNullPrincipalURI.h',
 ]
 
 EXPORTS.mozilla = [
     'BasePrincipal.h'
 ]
 
+SOURCES += [
+    # Compile this separately since nsExceptionHandler.h conflicts
+    # with something from nsNullPrincipal.cpp.
+    'BasePrincipal.cpp',
+]
+
 UNIFIED_SOURCES += [
-    'BasePrincipal.cpp',
     'DomainPolicy.cpp',
     'nsJSPrincipals.cpp',
     'nsNullPrincipal.cpp',
     'nsNullPrincipalURI.cpp',
     'nsPrincipal.cpp',
     'nsScriptSecurityManager.cpp',
     'nsSystemPrincipal.cpp',
 ]
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -22,16 +22,17 @@
 #include "mozilla/BasePrincipal.h"
 #include "nsSystemPrincipal.h"
 #include "nsPrincipal.h"
 #include "nsNullPrincipal.h"
 #include "DomainPolicy.h"
 #include "nsXPIDLString.h"
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
+#include "nsDocShell.h"
 #include "nsError.h"
 #include "nsDOMCID.h"
 #include "nsIXPConnect.h"
 #include "nsTextFormatter.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsIProperties.h"