Bug 1496503 - Move MOZ_CrashOOL to Assertions.h. r=froydnj
☠☠ backed out by d8a262837cd3 ☠ ☠
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 13 Nov 2018 23:47:36 +0000
changeset 446126 bfb4ee856c7115899960e3bd1fcf72b5e764314d
parent 446125 8482a89e69e442f845f8e05c8201fda5e55c9538
child 446127 d0b6c1fc149d58e8f3b177b28a3670046089f097
push id35034
push userccoroiu@mozilla.com
push dateWed, 14 Nov 2018 09:49:38 +0000
treeherdermozilla-central@d8a262837cd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1496503
milestone65.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 1496503 - Move MOZ_CrashOOL to Assertions.h. r=froydnj Ideally, we'd want the function to stay in Assertions.cpp, but that's only part of MFBT proper, and that doesn't have access to WalkTheStack like MOZ_CRASH has from being in Assertion.h, when included from Gecko code. Moving WalkTheStack to mozglue, putting it close together with MozStackWalk would be prefered, but that causes problems linking MFBT tests (which don't have access to mozglue), and other things. Overall, this was too deep a rabbit hole, and moving MOZ_CrashOOL to Assertions.h is much simpler. Since it's essentially the same as MOZ_CRASH, except it allows non-literal strings, we can make it inlined, and leave it to the compiler to drop the filename argument when it's not used. Differential Revision: https://phabricator.services.mozilla.com/D11718
mfbt/Assertions.cpp
mfbt/Assertions.h
--- a/mfbt/Assertions.cpp
+++ b/mfbt/Assertions.cpp
@@ -13,31 +13,16 @@ MOZ_BEGIN_EXTERN_C
 /*
  * The crash reason is defined as a global variable here rather than in the
  * crash reporter itself to make it available to all code, even libraries like
  * JS that don't link with the crash reporter directly. This value will only
  * be consumed if the crash reporter is used by the target application.
  */
 MFBT_DATA const char* gMozCrashReason = nullptr;
 
-#ifndef DEBUG
-MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
-MOZ_CrashOOL(int aLine, const char* aReason)
-#else
-MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
-MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason)
-#endif
-{
-#ifdef DEBUG
-  MOZ_ReportCrash(aReason, aFilename, aLine);
-#endif
-  gMozCrashReason = aReason;
-  MOZ_REALLY_CRASH(aLine);
-}
-
 static char sPrintfCrashReason[sPrintfCrashReasonSize] = {};
 
 // Accesses to this atomic are not included in web replay recordings, so that
 // if we crash in an area where recorded events are not allowed the true reason
 // for the crash is not obscured by a record/replay error.
 static mozilla::Atomic<bool, mozilla::SequentiallyConsistent,
                        mozilla::recordreplay::Behavior::DontPreserve> sCrashing(false);
 
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -296,25 +296,26 @@ MOZ_NoReturn(int aLine)
  * arbitrary strings from a potentially compromised process is not without risk.
  * If the string being passed is the result of a printf-style function,
  * consider using MOZ_CRASH_UNSAFE_PRINTF instead.
  *
  * @note This macro causes data collection because crash strings are annotated
  * to crash-stats and are publicly visible. Firefox data stewards must do data
  * review on usages of this macro.
  */
-#ifndef DEBUG
-MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
-MOZ_CrashOOL(int aLine, const char* aReason);
-#  define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__LINE__, reason)
-#else
-MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
-MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason);
-#  define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__FILE__, __LINE__, reason)
+static inline MOZ_COLD MOZ_NORETURN void
+MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason)
+{
+#ifdef DEBUG
+  MOZ_ReportCrash(aReason, aFilename, aLine);
 #endif
+  MOZ_CRASH_ANNOTATE(aReason);
+  MOZ_REALLY_CRASH(aLine);
+}
+#define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__FILE__, __LINE__, reason)
 
 static const size_t sPrintfMaxArgs = 4;
 static const size_t sPrintfCrashReasonSize = 1024;
 
 #ifndef DEBUG
 MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE MOZ_FORMAT_PRINTF(2, 3) void
 MOZ_CrashPrintf(int aLine, const char* aFormat, ...);
 #  define MOZ_CALL_CRASH_PRINTF(format, ...) \