From 061c4e65a0583d96b031a5faf54c5f398e7a1d06 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Fri, 18 Dec 2009 16:16:38 -0500 Subject: [PATCH] Bug 535802 - disable the Windows JIT crash dialog when running mochitests, r=ted --- build/automation.py.in | 1 + toolkit/xre/nsAppRunner.cpp | 111 ++++++++++++++++--------------- toolkit/xre/nsAppRunner.h | 6 ++ toolkit/xre/nsEmbedFunctions.cpp | 2 + 4 files changed, 67 insertions(+), 53 deletions(-) diff --git a/build/automation.py.in b/build/automation.py.in index 7fa1192f24c6..072a7e724030 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -451,6 +451,7 @@ def environment(env = None, xrePath = DIST_BIN, crashreporter = True): env['MOZ_CRASHREPORTER_DISABLE'] = '1' env['GNOME_DISABLE_CRASH_DIALOG'] = "1" + env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1' return env if IS_WIN32: diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 0b4f245851c0..e8b70fc63317 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -2631,20 +2631,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) nsSplashScreen *splashScreen = nsnull; #endif -#ifdef XP_WIN - /* On Windows XPSP3 and Windows Vista if DEP is configured off-by-default - we still want DEP protection: enable it explicitly and programmatically. - - This function is not available on WinXPSP2 so we dynamically load it. - */ - - HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); - SetProcessDEPPolicyFunc _SetProcessDEPPolicy = - (SetProcessDEPPolicyFunc) GetProcAddress(kernel32, "SetProcessDEPPolicy"); - if (_SetProcessDEPPolicy) - _SetProcessDEPPolicy(PROCESS_DEP_ENABLE); -#endif - nsresult rv; ArgResult ar; NS_TIMELINE_MARK("enter main"); @@ -2654,33 +2640,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) NS_BREAK(); #endif -#if defined (XP_WIN32) && !defined (WINCE) - // Suppress the "DLL Foo could not be found" dialog, such that if dependent - // libraries (such as GDI+) are not preset, we gracefully fail to load those - // XPCOM components, instead of being ungraceful. - UINT realMode = SetErrorMode(0); - realMode |= SEM_FAILCRITICALERRORS; - // If XRE_NO_WINDOWS_CRASH_DIALOG is set, suppress displaying the "This - // application has crashed" dialog box. This is mainly useful for - // automated testing environments, e.g. tinderbox, where there's no need - // for a dozen of the dialog boxes to litter the console - if (getenv("XRE_NO_WINDOWS_CRASH_DIALOG")) - realMode |= SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; - - SetErrorMode(realMode); - -#ifdef DEBUG - // Disable small heap allocator to get heapwalk() giving us - // accurate heap numbers. Win2k non-debug does not use small heap allocator. - // Win2k debug seems to be still using it. - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__set_sbh_threshold.asp - _set_sbh_threshold(0); -#endif -#endif - -#if defined(XP_UNIX) || defined(XP_BEOS) - InstallUnixSignalHandlers(argv[0]); -#endif + SetupErrorHandling(); #ifdef MOZ_ACCESSIBILITY_ATK // Reset GTK_MODULES, strip atk-bridge if exists @@ -2699,18 +2659,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) PR_SetEnv("NO_AT_BRIDGE=1"); #endif -#ifndef WINCE - // Unbuffer stdout, needed for tinderbox tests. - setbuf(stdout, 0); -#endif - -#if defined(FREEBSD) - // Disable all SIGFPE's on FreeBSD, as it has non-IEEE-conformant fp - // trap behavior that trips up on floating-point tests performed by - // the JS engine. See bugzilla bug 9967 details. - fpsetmask(0); -#endif - gArgc = argc; gArgv = argv; @@ -3713,3 +3661,60 @@ XRE_GetProcessType() #endif } +void +SetupErrorHandling() +{ +#ifdef XP_WIN + /* On Windows XPSP3 and Windows Vista if DEP is configured off-by-default + we still want DEP protection: enable it explicitly and programmatically. + + This function is not available on WinXPSP2 so we dynamically load it. + */ + + HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); + SetProcessDEPPolicyFunc _SetProcessDEPPolicy = + (SetProcessDEPPolicyFunc) GetProcAddress(kernel32, "SetProcessDEPPolicy"); + if (_SetProcessDEPPolicy) + _SetProcessDEPPolicy(PROCESS_DEP_ENABLE); +#endif + +#if defined (XP_WIN32) && !defined (WINCE) + // Suppress the "DLL Foo could not be found" dialog, such that if dependent + // libraries (such as GDI+) are not preset, we gracefully fail to load those + // XPCOM components, instead of being ungraceful. + UINT realMode = SetErrorMode(0); + realMode |= SEM_FAILCRITICALERRORS; + // If XRE_NO_WINDOWS_CRASH_DIALOG is set, suppress displaying the "This + // application has crashed" dialog box. This is mainly useful for + // automated testing environments, e.g. tinderbox, where there's no need + // for a dozen of the dialog boxes to litter the console + if (getenv("XRE_NO_WINDOWS_CRASH_DIALOG")) + realMode |= SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; + + SetErrorMode(realMode); + +#ifdef DEBUG + // Disable small heap allocator to get heapwalk() giving us + // accurate heap numbers. Win2k non-debug does not use small heap allocator. + // Win2k debug seems to be still using it. + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__set_sbh_threshold.asp + _set_sbh_threshold(0); +#endif +#endif + +#if defined(XP_UNIX) || defined(XP_BEOS) + InstallUnixSignalHandlers(argv[0]); +#endif + +#ifndef WINCE + // Unbuffer stdout, needed for tinderbox tests. + setbuf(stdout, 0); +#endif + +#if defined(FREEBSD) + // Disable all SIGFPE's on FreeBSD, as it has non-IEEE-conformant fp + // trap behavior that trips up on floating-point tests performed by + // the JS engine. See bugzilla bug 9967 details. + fpsetmask(0); +#endif +} diff --git a/toolkit/xre/nsAppRunner.h b/toolkit/xre/nsAppRunner.h index eb7b7ce7187c..9fdc15b22f81 100644 --- a/toolkit/xre/nsAppRunner.h +++ b/toolkit/xre/nsAppRunner.h @@ -190,4 +190,10 @@ extern GeckoProcessType sChildProcessType; } #endif +/** + * Set up platform specific error handling such as suppressing DLL load dialog + * and the JIT debugger on Windows, and install unix signal handlers. + */ +void SetupErrorHandling(); + #endif // nsAppRunner_h__ diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 7a39f79f4866..795c29d500db 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -262,6 +262,8 @@ XRE_InitChildProcess(int aArgc, NS_ENSURE_ARG_POINTER(aArgv); NS_ENSURE_ARG_POINTER(aArgv[0]); + SetupErrorHandling(); + sChildProcessType = aProcess; #if defined(MOZ_WIDGET_GTK2)