Bug 755724 - Initialize trace malloc before calling NS_NewLocalFile in nsBrowserApp.cpp. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 19 Jan 2013 09:40:02 +0100
changeset 119345 ab31d2237244ccfc348c1562bbd6776c2495f7d7
parent 119344 f02b8f754b74b23757b0ff6e6439893fc6f1f584
child 119346 204b95febb133df8062ab60e393ca8b654f31d07
push id21623
push usermh@glandium.org
push dateSat, 19 Jan 2013 08:47:28 +0000
treeherdermozilla-inbound@6b280e155484 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs755724
milestone21.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 755724 - Initialize trace malloc before calling NS_NewLocalFile in nsBrowserApp.cpp. r=bsmedberg
browser/app/nsBrowserApp.cpp
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -87,26 +87,16 @@ static bool IsArg(const char* arg, const
 #if defined(XP_WIN) || defined(XP_OS2)
   if (*arg == '/')
     return !strcasecmp(++arg, s);
 #endif
 
   return false;
 }
 
-/**
- * A helper class which calls NS_LogInit/NS_LogTerm in its scope.
- */
-class ScopedLogging
-{
-public:
-  ScopedLogging() { NS_LogInit(); }
-  ~ScopedLogging() { NS_LogTerm(); }
-};
-
 XRE_GetFileFromPathType XRE_GetFileFromPath;
 XRE_CreateAppDataType XRE_CreateAppData;
 XRE_FreeAppDataType XRE_FreeAppData;
 #ifdef XRE_HAS_DLL_BLOCKLIST
 XRE_SetupDllBlocklistType XRE_SetupDllBlocklist;
 #endif
 XRE_TelemetryAccumulateType XRE_TelemetryAccumulate;
 XRE_StartupTimelineRecordType XRE_StartupTimelineRecord;
@@ -310,24 +300,26 @@ InitXPCOMGlue(const char *argv0, nsIFile
   }
 
   rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
   if (NS_FAILED(rv)) {
     Output("Couldn't load XRE functions.\n");
     return rv;
   }
 
+  NS_LogInit();
+
   // chop XPCOM_DLL off exePath
   *lastSlash = '\0';
 #ifdef XP_WIN
-  NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), false,
-                  xreDirectory);
+  rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), false,
+                       xreDirectory);
 #else
-  NS_NewNativeLocalFile(nsDependentCString(exePath), false,
-                        xreDirectory);
+  rv = NS_NewNativeLocalFile(nsDependentCString(exePath), false,
+                             xreDirectory);
 #endif
 
   return rv;
 }
 
 int main(int argc, char* argv[])
 {
   PRTime start = _PR_Now();
@@ -377,21 +369,19 @@ int main(int argc, char* argv[])
     struct rusage newRUsage;
     if (!getrusage(RUSAGE_SELF, &newRUsage)) {
       XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS,
                               int(newRUsage.ru_majflt - initialRUsage.ru_majflt));
     }
 #endif
   }
 
-  int result;
-  {
-    ScopedLogging log;
-    result = do_main(argc, argv, xreDirectory);
-  }
+  int result = do_main(argc, argv, xreDirectory);
+
+  NS_LogTerm();
 
 #ifdef XP_MACOSX
   // Allow writes again. While we would like to catch writes from static
   // destructors to allow early exits to use _exit, we know that there is
   // at least one such write that we don't control (see bug 826029). For
   // now we enable writes again and early exits will have to use exit instead
   // of _exit.
   XRE_DisableWritePoisoning();