Skip to content

Commit

Permalink
[vm] Do not suppress WER when running VM outside of our test suite.
Browse files Browse the repository at this point in the history
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 <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
  • Loading branch information
mraleph authored and commit-bot@chromium.org committed Dec 12, 2018
1 parent 4ed049d commit 6bf4d2a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
24 changes: 19 additions & 5 deletions runtime/bin/platform_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ class PlatformWin {
// Disable the message box for assertions in the CRT in Debug builds.
// See: https://msdn.microsoft.com/en-us/library/1y71x448.aspx
_CrtSetReportMode(_CRT_ASSERT, 0);

// Disable dialog boxes for "critical" errors or when OpenFile cannot find
// the requested file. See:
// the requested file. However only disable error boxes for general
// protection faults if an environment variable is set. Passing
// SEM_NOGPFAULTERRORBOX completely disables WindowsErrorReporting (WER)
// for the process, which means users loose ability to enable local dump
// archiving to collect minidumps for Dart VM crashes.
// Our test runner would set DART_SUPPRESS_WER to suppress WER UI during
// test suite execution.
// See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX |
SEM_NOGPFAULTERRORBOX);
UINT uMode = SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
if (getenv("DART_SUPPRESS_WER") != nullptr) {
uMode |= SEM_NOGPFAULTERRORBOX;
}
SetErrorMode(uMode);
#ifndef PRODUCT
// Set up global exception handler to be able to dump stack trace on crash.
SetExceptionHandler();
Expand All @@ -71,8 +81,12 @@ class PlatformWin {
ExceptionInfo->ExceptionRecord->ExceptionFlags,
ExceptionInfo->ExceptionRecord->ExceptionAddress);
Dart_DumpNativeStackTrace(ExceptionInfo->ContextRecord);
const int kAbortExitCode = 3;
Platform::Exit(kAbortExitCode);
Console::RestoreConfig();
// TODO(zra): Remove once VM shuts down cleanly.
::dart::private_flag_windows_run_tls_destructors = false;
// Note: we want to abort(...) here instead of exiting because exiting
// would not cause WER to generate a minidump.
abort();
}
return EXCEPTION_CONTINUE_SEARCH;
}
Expand Down
11 changes: 8 additions & 3 deletions tools/testing/dart/test_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,14 @@ abstract class TestSuite {
_environmentOverrides = {
'DART_CONFIGURATION': configuration.configurationDirectory,
};
if (configuration.copyCoreDumps && Platform.isWindows) {
_environmentOverrides['DART_CRASHPAD_HANDLER'] =
new Path(buildDir + '/crashpad_handler.exe').absolute.toNativePath();
if (Platform.isWindows) {
_environmentOverrides['DART_SUPPRESS_WER'] = '1';
if (configuration.copyCoreDumps) {
_environmentOverrides['DART_CRASHPAD_HANDLER'] =
new Path(buildDir + '/crashpad_handler.exe')
.absolute
.toNativePath();
}
}
}

Expand Down

0 comments on commit 6bf4d2a

Please sign in to comment.