Skip to content

Commit 6bf4d2a

Browse files
mralephcommit-bot@chromium.org
authored andcommitted
[vm] Do not suppress WER when running VM outside of our test suite.
We prevent our crashing tests from hitting timeouts on the bots by disabling Windows Error Reporting UI via SetErrorMode. However this also disables builtin crash dump generation functionality that WER has. This change moves WER suppression for GP faults under a flag to make sure that we can collect crash dumps when VM crashes on user machines. We also make sure that our exception handler call abort() instead of calling exit() - because exit would not cause WER to generate a dump. Bug: flutter/flutter#22558 Change-Id: I42f3e31cfaaa578f6a040b8f10621e5663cddc09 Reviewed-on: https://dart-review.googlesource.com/c/87061 Auto-Submit: Vyacheslav Egorov <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Vyacheslav Egorov <[email protected]>
1 parent 4ed049d commit 6bf4d2a

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

runtime/bin/platform_win.cc

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ class PlatformWin {
4343
// Disable the message box for assertions in the CRT in Debug builds.
4444
// See: https://msdn.microsoft.com/en-us/library/1y71x448.aspx
4545
_CrtSetReportMode(_CRT_ASSERT, 0);
46+
4647
// Disable dialog boxes for "critical" errors or when OpenFile cannot find
47-
// the requested file. See:
48+
// the requested file. However only disable error boxes for general
49+
// protection faults if an environment variable is set. Passing
50+
// SEM_NOGPFAULTERRORBOX completely disables WindowsErrorReporting (WER)
51+
// for the process, which means users loose ability to enable local dump
52+
// archiving to collect minidumps for Dart VM crashes.
53+
// Our test runner would set DART_SUPPRESS_WER to suppress WER UI during
54+
// test suite execution.
4855
// See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
49-
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX |
50-
SEM_NOGPFAULTERRORBOX);
56+
UINT uMode = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
57+
if (getenv("DART_SUPPRESS_WER") != nullptr) {
58+
uMode |= SEM_NOGPFAULTERRORBOX;
59+
}
60+
SetErrorMode(uMode);
5161
#ifndef PRODUCT
5262
// Set up global exception handler to be able to dump stack trace on crash.
5363
SetExceptionHandler();
@@ -71,8 +81,12 @@ class PlatformWin {
7181
ExceptionInfo->ExceptionRecord->ExceptionFlags,
7282
ExceptionInfo->ExceptionRecord->ExceptionAddress);
7383
Dart_DumpNativeStackTrace(ExceptionInfo->ContextRecord);
74-
const int kAbortExitCode = 3;
75-
Platform::Exit(kAbortExitCode);
84+
Console::RestoreConfig();
85+
// TODO(zra): Remove once VM shuts down cleanly.
86+
::dart::private_flag_windows_run_tls_destructors = false;
87+
// Note: we want to abort(...) here instead of exiting because exiting
88+
// would not cause WER to generate a minidump.
89+
abort();
7690
}
7791
return EXCEPTION_CONTINUE_SEARCH;
7892
}

tools/testing/dart/test_suite.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,14 @@ abstract class TestSuite {
128128
_environmentOverrides = {
129129
'DART_CONFIGURATION': configuration.configurationDirectory,
130130
};
131-
if (configuration.copyCoreDumps && Platform.isWindows) {
132-
_environmentOverrides['DART_CRASHPAD_HANDLER'] =
133-
new Path(buildDir + '/crashpad_handler.exe').absolute.toNativePath();
131+
if (Platform.isWindows) {
132+
_environmentOverrides['DART_SUPPRESS_WER'] = '1';
133+
if (configuration.copyCoreDumps) {
134+
_environmentOverrides['DART_CRASHPAD_HANDLER'] =
135+
new Path(buildDir + '/crashpad_handler.exe')
136+
.absolute
137+
.toNativePath();
138+
}
134139
}
135140
}
136141

0 commit comments

Comments
 (0)