Bug 1081283 - Use the correct calling convention on InitDwriteBG; r=jrmuizel
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 10 Oct 2014 18:30:46 -0400
changeset 209967 4ef90fdc2c5895c81cdf6434ce54a88dd7b3d499
parent 209966 d27ce1e75719e417328b570bec2c6dbcbd5e1de7
child 209968 94e7f3c3969c899f753098afb6639b811fbc7d1c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjrmuizel
bugs1081283
milestone35.0a1
Bug 1081283 - Use the correct calling convention on InitDwriteBG; r=jrmuizel Otherwise our stack is misaligned by the time we return from this. This misalignment doesn't cause a crash with the Winodws thread startup code, but it does with ASAN because it does many things after the thread entry point exits.
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2848,17 +2848,17 @@ static void LogRegistryEvent(const wchar
   }
 }
 #else
 
 #define LOGREGISTRY(msg)
 
 #endif
 
-static DWORD InitDwriteBG(LPVOID lpdwThreadParam)
+static DWORD WINAPI InitDwriteBG(LPVOID lpdwThreadParam)
 {
   SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN);
   LOGREGISTRY(L"loading dwrite.dll");
   HMODULE dwdll = LoadLibraryW(L"dwrite.dll");
   if (dwdll) {
     decltype(DWriteCreateFactory)* createDWriteFactory = (decltype(DWriteCreateFactory)*)
       GetProcAddress(dwdll, "DWriteCreateFactory");
     if (createDWriteFactory) {
@@ -3038,18 +3038,17 @@ XREMain::XRE_mainInit(bool* aExitFlag)
     // calls cause the IDWriteFactory object to communicate with the FntCache
     // service with a timeout; if there's no response after the timeout, the
     // DirectWrite client library will assume the service isn't around and do
     // manual font file I/O on _all_ system fonts.  To avoid this, load the
     // dwrite library and create a factory as early as possible so that the
     // FntCache service is ready by the time it's needed.
 
     if (IsVistaOrLater()) {
-      CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)&InitDwriteBG,
-                   nullptr, 0, nullptr);
+      CreateThread(nullptr, 0, &InitDwriteBG, nullptr, 0, nullptr);
     }
   }
 #endif
 
 #ifdef XP_UNIX
   const char *home = PR_GetEnv("HOME");
   if (!home || !*home) {
     struct passwd *pw = getpwuid(geteuid());