Bug 1424505: Ensure at least one consistent reference to the COM MTA at all times on Windows 7; r=jimm
authorAaron Klotz <aklotz@mozilla.com>
Tue, 06 Mar 2018 17:06:54 -0700
changeset 462102 35129c889938eeefd8ccc81cf78a223e045e7f00
parent 462101 b87c9f3e9d5d314b553cd411a1554fa7cd11528f
child 462103 32da8b4abfd7adb3f60b2f138be37e4d43637283
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1424505
milestone60.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 1424505: Ensure at least one consistent reference to the COM MTA at all times on Windows 7; r=jimm
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -96,18 +96,20 @@
 
 #ifdef XP_WIN
 #include "nsIWinAppHelper.h"
 #include <windows.h>
 #include <intrin.h>
 #include <math.h>
 #include "cairo/cairo-features.h"
 #include "mozilla/WindowsDllBlocklist.h"
+#include "mozilla/mscom/EnsureMTA.h"
 #include "mozilla/mscom/MainThreadRuntime.h"
 #include "mozilla/widget/AudioSession.h"
+#include "mozilla/WindowsVersion.h"
 
 #ifndef PROCESS_DEP_ENABLE
 #define PROCESS_DEP_ENABLE 0x1
 #endif
 #endif
 
 #if defined(MOZ_CONTENT_SANDBOX)
 #include "mozilla/SandboxSettings.h"
@@ -4315,16 +4317,26 @@ XREMain::XRE_mainRun()
   nsresult rv = NS_OK;
   NS_ASSERTION(mScopedXPCOM, "Scoped xpcom not initialized.");
 
 #if defined(XP_WIN)
   RefPtr<mozilla::DllServices> dllServices(mozilla::DllServices::Get());
   auto dllServicesDisable = MakeScopeExit([&dllServices]() {
     dllServices->Disable();
   });
+
+#if defined(NIGHTLY_BUILD)
+  if (!IsWin8OrLater()) {
+    // On Windows 7, ensure that the COM MTA remains alive for the life of the
+    // process. We have seen multiple crashes on that OS when the MTA is
+    // repeatedly set up and torn down, so maintaining at least one consistent
+    // reference should prevent those.
+    mscom::EnsureMTA();
+  }
+#endif // defined(NIGHTLY_BUILD)
 #endif // defined(XP_WIN)
 
 #ifdef NS_FUNCTION_TIMER
   // initialize some common services, so we don't pay the cost for these at odd times later on;
   // SetWindowCreator -> ChromeRegistry -> IOService -> SocketTransportService -> (nspr wspm init), Prefs
   {
     nsCOMPtr<nsISupports> comp;