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.
--- 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());