From 17a74944cad9ce88e1e9c46a67bdf953d398d827 Mon Sep 17 00:00:00 2001 From: Yoshi Huang Date: Fri, 29 Jan 2016 15:19:56 -0800 Subject: [PATCH] Bug 1240651 - Annotate addonId into crash report (r=bholley) --- caps/BasePrincipal.cpp | 11 ++++++++++- caps/moz.build | 7 ++++++- caps/nsScriptSecurityManager.cpp | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index 052571d6995..aa4b7b49ab1 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -7,6 +7,9 @@ #include "mozilla/BasePrincipal.h" #include "nsDocShell.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif #include "nsIAddonPolicyService.h" #include "nsIContentSecurityPolicy.h" #include "nsIObjectInputStream.h" @@ -121,7 +124,13 @@ OriginAttributes::CreateSuffix(nsACString& aStr) const } 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); } diff --git a/caps/moz.build b/caps/moz.build index 365e8ddf8a6..92afc4b7b9e 100644 --- a/caps/moz.build +++ b/caps/moz.build @@ -32,8 +32,13 @@ EXPORTS.mozilla = [ 'BasePrincipal.h' ] -UNIFIED_SOURCES += [ +SOURCES += [ + # Compile this separately since nsExceptionHandler.h conflicts + # with something from nsNullPrincipal.cpp. 'BasePrincipal.cpp', +] + +UNIFIED_SOURCES += [ 'DomainPolicy.cpp', 'nsJSPrincipals.cpp', 'nsNullPrincipal.cpp', diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index febd4de1222..3ab4accdd40 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -27,6 +27,7 @@ #include "nsXPIDLString.h" #include "nsCRT.h" #include "nsCRTGlue.h" +#include "nsDocShell.h" #include "nsError.h" #include "nsDOMCID.h" #include "nsIXPConnect.h"