Bug 1412048 - Replace NS_RUNTIMEABORT(var) with MOZ_CRASH_UNSAFE_OOL(var). r?froydnj data-review?francois draft
authorChris Peterson <cpeterson@mozilla.com>
Tue, 24 Oct 2017 23:38:38 -0700
changeset 686976 debaad5399ec8f9f7a2112fb16dd8ff7dd866e4a
parent 686975 500f2a55730beddad63e768e9cbac72b05e59d4c
child 686977 2d79f13307067bf41c9e4d6996a25e0b901879e3
push id86367
push usercpeterson@mozilla.com
push dateThu, 26 Oct 2017 18:05:05 +0000
reviewersfroydnj
bugs1412048
milestone58.0a1
Bug 1412048 - Replace NS_RUNTIMEABORT(var) with MOZ_CRASH_UNSAFE_OOL(var). r?froydnj data-review?francois And remove unreachable code after MOZ_CRASH_UNSAFE_OOL(). MOZ_CRASH_UNSAFE_OOL 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. However, all the crash strings this patch collects with MOZ_CRASH_UNSAFE_OOL are already collected with NS_RUNTIMEABORT. MozReview-Commit-ID: IHmJfuxXSqw
gfx/layers/opengl/GLBlitTextureImageHelper.cpp
gfx/thebes/gfxTextRun.cpp
ipc/glue/MessageChannel.cpp
ipc/glue/ProtocolUtils.cpp
layout/style/nsLayoutStylesheetCache.cpp
netwerk/ipc/NeckoCommon.h
toolkit/xre/nsGDKErrorHandler.cpp
toolkit/xre/nsX11ErrorHandler.cpp
xpcom/base/nsTraceRefcnt.cpp
xpcom/build/XPCOMInit.cpp
--- a/gfx/layers/opengl/GLBlitTextureImageHelper.cpp
+++ b/gfx/layers/opengl/GLBlitTextureImageHelper.cpp
@@ -184,17 +184,17 @@ GLBlitTextureImageHelper::SetBlitFramebu
     if (aTexture && (result != LOCAL_GL_FRAMEBUFFER_COMPLETE)) {
         nsAutoCString msg;
         msg.AppendLiteral("Framebuffer not complete -- error 0x");
         msg.AppendInt(result, 16);
         // Note: if you are hitting this, it is likely that
         // your texture is not texture complete -- that is, you
         // allocated a texture name, but didn't actually define its
         // size via a call to TexImage2D.
-        NS_RUNTIMEABORT(msg.get());
+        MOZ_CRASH_UNSAFE_OOL(msg.get());
     }
 }
 
 void
 GLBlitTextureImageHelper::UseBlitProgram()
 {
     // XXX: GLBlitTextureImageHelper doesn't use ShaderProgramOGL
     // so we need to Reset the program
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -2090,17 +2090,17 @@ gfxFontGroup::GetDefaultFont()
 #endif
         gfxCriticalError() << fontInitInfo.get();
 
         char msg[256]; // CHECK buffer length if revising message below
         nsAutoString familiesString;
         mFamilyList.ToString(familiesString);
         SprintfLiteral(msg, "unable to find a usable font (%.220s)",
                        NS_ConvertUTF16toUTF8(familiesString).get());
-        NS_RUNTIMEABORT(msg);
+        MOZ_CRASH_UNSAFE_OOL(msg);
     }
 
     return mDefaultFont.get();
 }
 
 gfxFont*
 gfxFontGroup::GetFirstValidFont(uint32_t aCh)
 {
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -2779,17 +2779,17 @@ MessageChannel::DebugAbort(const char* f
     while (!pending.isEmpty()) {
         printf_stderr("    [ %s%s ]\n",
                       pending.getFirst()->Msg().is_interrupt() ? "intr" :
                       (pending.getFirst()->Msg().is_sync() ? "sync" : "async"),
                       pending.getFirst()->Msg().is_reply() ? "reply" : "");
         pending.popFirst();
     }
 
-    NS_RUNTIMEABORT(why);
+    MOZ_CRASH_UNSAFE_OOL(why);
 }
 
 void
 MessageChannel::DumpInterruptStack(const char* const pfx) const
 {
     NS_WARNING_ASSERTION(
       MessageLoop::current() != mWorkerLoop,
       "The worker thread had better be paused in a debugger!");
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -298,24 +298,24 @@ FatalError(const char* aProtocolName, co
                                        nsDependentCString(aProtocolName));
     CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorMsg"),
                                        nsDependentCString(aMsg));
     AnnotateSystemError();
 #endif
     MOZ_CRASH("IPC FatalError in the parent process!");
   } else {
     formattedMessage.AppendLiteral("\". abort()ing as a result.");
-    NS_RUNTIMEABORT(formattedMessage.get());
+    MOZ_CRASH_UNSAFE_OOL(formattedMessage.get());
   }
 }
 
 void
 LogicError(const char* aMsg)
 {
-  NS_RUNTIMEABORT(aMsg);
+  MOZ_CRASH_UNSAFE_OOL(aMsg);
 }
 
 void
 ActorIdReadError(const char* aActorDescription)
 {
   nsPrintfCString message("Error deserializing id for %s", aActorDescription);
   NS_RUNTIMEABORT(message.get());
 }
--- a/layout/style/nsLayoutStylesheetCache.cpp
+++ b/layout/style/nsLayoutStylesheetCache.cpp
@@ -768,17 +768,18 @@ ErrorLoadingSheet(nsIURI* aURI, const ch
       cs->LogStringMessage(NS_ConvertUTF8toUTF16(errorMessage).get());
       return;
     }
   }
 
 #ifdef MOZ_CRASHREPORTER
   AnnotateCrashReport(aURI);
 #endif
-  NS_RUNTIMEABORT(errorMessage.get());
+
+  MOZ_CRASH_UNSAFE_OOL(errorMessage.get());
 }
 
 void
 nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
                                    RefPtr<StyleSheet>* aSheet,
                                    SheetParsingMode aParsingMode,
                                    FailureAction aFailureAction)
 {
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -32,17 +32,17 @@ class TabChild;
   do {                                                                         \
     bool abort = NECKO_ERRORS_ARE_FATAL_DEFAULT;                               \
     const char *e = PR_GetEnv("NECKO_ERRORS_ARE_FATAL");                       \
     if (e)                                                                     \
       abort = (*e == '0') ? false : true;                                      \
     if (abort) {                                                               \
       msg.AppendLiteral(" (set NECKO_ERRORS_ARE_FATAL=0 in your environment "  \
                         "to convert this error into a warning.)");             \
-      NS_RUNTIMEABORT(msg.get());                                              \
+      MOZ_CRASH_UNSAFE_OOL(msg.get());                                         \
     } else {                                                                   \
       msg.AppendLiteral(" (set NECKO_ERRORS_ARE_FATAL=1 in your environment "  \
                         "to convert this warning into a fatal error.)");       \
       NS_WARNING(msg.get());                                                   \
     }                                                                          \
   } while (0)
 
 #define DROP_DEAD()                                                            \
--- a/toolkit/xre/nsGDKErrorHandler.cpp
+++ b/toolkit/xre/nsGDKErrorHandler.cpp
@@ -35,61 +35,61 @@ GdkErrorHandler(const gchar *log_domain,
     char *endptr;
 
     /* Parse Gdk X Window error message which has this format:
      * (Details: serial XXXX error_code XXXX request_code XXXX (XXXX) minor_code XXXX)
      */
     NS_NAMED_LITERAL_CSTRING(serialString, "(Details: serial ");
     int32_t start = buffer.Find(serialString);
     if (start == kNotFound)
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     start += serialString.Length();
     errno = 0;
     event.serial = strtol(buffer.BeginReading() + start, &endptr, 10);
     if (errno)
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     NS_NAMED_LITERAL_CSTRING(errorCodeString, " error_code ");
     if (!StringBeginsWith(Substring(endptr, buffer.EndReading()), errorCodeString))
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     errno = 0;
     event.error_code = strtol(endptr + errorCodeString.Length(), &endptr, 10);
     if (errno)
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     NS_NAMED_LITERAL_CSTRING(requestCodeString, " request_code ");
     if (!StringBeginsWith(Substring(endptr, buffer.EndReading()), requestCodeString))
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     errno = 0;
     event.request_code = strtol(endptr + requestCodeString.Length(), &endptr, 10);
     if (errno)
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     NS_NAMED_LITERAL_CSTRING(minorCodeString, " minor_code ");
     start = buffer.Find(minorCodeString, /* aIgnoreCase = */ false,
                         endptr - buffer.BeginReading());
     if (!start)
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     errno = 0;
     event.minor_code = strtol(buffer.BeginReading() + start + minorCodeString.Length(), nullptr, 10);
     if (errno)
-      NS_RUNTIMEABORT(message);
+      MOZ_CRASH_UNSAFE_OOL(message);
 
     event.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
     // Gdk does not provide resource ID
     event.resourceid = 0;
 
     X11Error(event.display, &event);
   } else {
     g_log_default_handler(log_domain, log_level, message, user_data);
-    NS_RUNTIMEABORT(message);
+    MOZ_CRASH_UNSAFE_OOL(message);
   }
 }
 
 void
 InstallGdkErrorHandler()
 {
   g_log_set_handler("Gdk",
                     (GLogLevelFlags)(G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION),
--- a/toolkit/xre/nsX11ErrorHandler.cpp
+++ b/toolkit/xre/nsX11ErrorHandler.cpp
@@ -139,18 +139,17 @@ X11Error(Display *display, XErrorEvent *
   // MOZ_X_SYNC=1 will not be necessary, but we don't have a table to tell us
   // which requests get a synchronous reply.
   if (!PR_GetEnv("MOZ_X_SYNC")) {
     notes.AppendLiteral("\nRe-running with MOZ_X_SYNC=1 in the environment may give a more helpful backtrace.");
   }
 #endif
 #endif
 
-  NS_RUNTIMEABORT(notes.get());
-  return 0; // not reached
+  MOZ_CRASH_UNSAFE_OOL(notes.get());
 }
 }
 
 void
 InstallX11ErrorHandler()
 {
   XSetErrorHandler(X11Error);
 
--- a/xpcom/base/nsTraceRefcnt.cpp
+++ b/xpcom/base/nsTraceRefcnt.cpp
@@ -161,17 +161,17 @@ struct nsTraceRefcntStats
 static const char kStaticCtorDtorWarning[] =
   "XPCOM objects created/destroyed from static ctor/dtor";
 
 static void
 AssertActivityIsLegal()
 {
   if (gActivityTLS == BAD_TLS_INDEX || PR_GetThreadPrivate(gActivityTLS)) {
     if (PR_GetEnv("MOZ_FATAL_STATIC_XPCOM_CTORS_DTORS")) {
-      NS_RUNTIMEABORT(kStaticCtorDtorWarning);
+      MOZ_CRASH_UNSAFE_OOL(kStaticCtorDtorWarning);
     } else {
       NS_WARNING(kStaticCtorDtorWarning);
     }
   }
 }
 #  define ASSERT_ACTIVITY_IS_LEGAL              \
   do {                                          \
     AssertActivityIsLegal();                    \
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -670,17 +670,17 @@ NS_InitXPCOM2(nsIServiceManager** aResul
   nsAutoCString nativeGREPath;
   greDir->GetNativePath(nativeGREPath);
   u_setDataDirectory(nativeGREPath.get());
 #endif
 
   // Initialize the JS engine.
   const char* jsInitFailureReason = JS_InitWithFailureDiagnostic();
   if (jsInitFailureReason) {
-    NS_RUNTIMEABORT(jsInitFailureReason);
+    MOZ_CRASH_UNSAFE_OOL(jsInitFailureReason);
   }
   sInitializedJS = true;
 
   rv = nsComponentManagerImpl::gComponentManager->Init();
   if (NS_FAILED(rv)) {
     NS_RELEASE(nsComponentManagerImpl::gComponentManager);
     return rv;
   }