Bug 535802 - disable the Windows JIT crash dialog when running mochitests, r=ted

This commit is contained in:
Benjamin Smedberg 2009-12-18 16:16:38 -05:00
parent 7acda4d6cc
commit cfc6020e91
4 changed files with 67 additions and 53 deletions

View File

@ -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:

View File

@ -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
}

View File

@ -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__

View File

@ -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)