Bug 840758 - Get the profile directory earlier. r=BenWa.
authorRafael Ávila de Espíndola <respindola@mozilla.org>
Wed, 13 Feb 2013 08:08:40 -0500
changeset 131615 fa1f52704c9ec098b8601bd57a30e822100d8bfc
parent 131614 d3e16515f630456647e2064d908ccf5c929d0b0d
child 131616 3ed3e656a08937417fcdf1427b1b6a06d919b895
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs840758
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 840758 - Get the profile directory earlier. r=BenWa.
xpcom/build/mozPoisonWrite.h
xpcom/build/mozPoisonWriteBase.cpp
xpcom/build/mozPoisonWriteBase.h
xpcom/build/mozPoisonWriteMac.cpp
xpcom/build/mozPoisonWriteWin.cpp
xpcom/build/nsXPComInit.cpp
--- a/xpcom/build/mozPoisonWrite.h
+++ b/xpcom/build/mozPoisonWrite.h
@@ -21,15 +21,16 @@ MOZ_END_EXTERN_C
 namespace mozilla {
 enum ShutdownChecksMode {
   SCM_CRASH,
   SCM_RECORD,
   SCM_NOTHING
 };
 extern ShutdownChecksMode gShutdownChecks;
 
+void InitWritePoisoning();
 void PoisonWrite();
 void DisableWritePoisoning();
 void EnableWritePoisoning();
 }
 #endif
 
 #endif
--- a/xpcom/build/mozPoisonWriteBase.cpp
+++ b/xpcom/build/mozPoisonWriteBase.cpp
@@ -36,17 +36,17 @@ static char *sProfileDirectory = NULL;
 
 std::vector<int>& getDebugFDs() {
   // We have to use new as some write happen during static destructors
   // so an static std::vector might be destroyed while we still need it.
   static std::vector<int> *DebugFDs = new std::vector<int>();
   return *DebugFDs;
 }
 
-void PoisonWriteBase()
+void InitWritePoisoning()
 {
   nsCOMPtr<nsIFile> mozFile;
   NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mozFile));
   if (mozFile) {
     nsAutoCString nativePath;
     nsresult rv = mozFile->GetNativePath(nativePath);
     if (NS_SUCCEEDED(rv)) {
       sProfileDirectory = PL_strdup(nativePath.get());
--- a/xpcom/build/mozPoisonWriteBase.h
+++ b/xpcom/build/mozPoisonWriteBase.h
@@ -39,17 +39,16 @@ public:
   }
 
   DebugFDAutoLock() : Scoped<DebugFDAutoLockTraits>(getDebugFDsLock()) {
     PR_Lock(get());
   }
 };
 
 bool PoisonWriteEnabled();
-void PoisonWriteBase();
 bool ValidWriteAssert(bool ok);
 void BaseCleanup();
 // This method should always be called with the debugFDs lock.
 // Note: MSVC Local static is NOT thread safe
 // http://stackoverflow.com/questions/10585928/is-static-init-thread-safe-with-vc2010
 std::vector<int>& getDebugFDs();
 
 }
--- a/xpcom/build/mozPoisonWriteMac.cpp
+++ b/xpcom/build/mozPoisonWriteMac.cpp
@@ -242,18 +242,16 @@ void PoisonWrite() {
     MOZ_ASSERT(!WritesArePoisoned);
     if (WritesArePoisoned)
         return;
     WritesArePoisoned = true;
 
     if (!PoisonWriteEnabled())
         return;
 
-    PoisonWriteBase();
-
     for (int i = 0; i < NumFunctions; ++i) {
         FuncData *d = Functions[i];
         if (!d->Function)
             d->Function = dlsym(RTLD_DEFAULT, d->Name);
         if (!d->Function)
             continue;
         DebugOnly<mach_error_t> t = mach_override_ptr(d->Function, d->Wrapper,
                                            &d->Buffer);
--- a/xpcom/build/mozPoisonWriteWin.cpp
+++ b/xpcom/build/mozPoisonWriteWin.cpp
@@ -43,15 +43,13 @@ void PoisonWrite() {
   MOZ_ASSERT(!WritesArePoisoned);
   if (WritesArePoisoned)
     return;
   WritesArePoisoned = true;
 
   if (!PoisonWriteEnabled())
     return;
 
-  PoisonWriteBase();
-
   sNtDllInterceptor.Init("ntdll.dll");
   sNtDllInterceptor.AddHook("NtFlushBuffersFile", reinterpret_cast<intptr_t>(patched_FlushBuffersFile), reinterpret_cast<void**>(&gOriginalFlushBuffersFile));
 }
 }
 
--- a/xpcom/build/nsXPComInit.cpp
+++ b/xpcom/build/nsXPComInit.cpp
@@ -595,16 +595,20 @@ ShutdownXPCOM(nsIServiceManager* servMgr
         }
     }
 
     // Free ClearOnShutdown()'ed smart pointers.  This needs to happen *after*
     // we've finished notifying observers of XPCOM shutdown, because shutdown
     // observers themselves might call ClearOnShutdown().
     mozilla::KillClearOnShutdown();
 
+    // Write poisoning needs to find the profile directory, so it has to
+    // be initialized before mozilla::services::Shutdown.
+    InitWritePoisoning();
+
     // XPCOM is officially in shutdown mode NOW
     // Set this only after the observers have been notified as this
     // will cause servicemanager to become inaccessible.
     mozilla::services::Shutdown();
 
 #ifdef DEBUG_dougt
     fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n");
 #endif