Skip to content

Commit 7297309

Browse files
committed
Don't abort for non-main thread NaCl crash
1 parent a5b850e commit 7297309

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/common/System.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ void SetupCrashHandler()
342342
#elif defined(__native_client__)
343343
static void CrashHandler(const void* data, size_t n)
344344
{
345+
// Note: this only works on the main thread. Otherwise we hit
346+
// Sys::Error("SendMsg from non-main VM thread");
345347
VM::CrashDump(static_cast<const uint8_t*>(data), n);
346348
Sys::Error("Crashed with NaCl exception");
347349
}

src/shared/VMMain.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,16 @@ static char realErrorMessage[256];
106106
void Sys::Error(Str::StringRef message)
107107
{
108108
if (!OnMainThread()) {
109-
// On a non-main thread we can't rely on IPC, so we may not be able to communicate the
110-
// error message. So try to trigger a crash dump instead (exiting with abort() triggers
111-
// one but exiting with _exit() doesn't). This will give something to work with when
112-
// debugging. (For the main thread case a message is usually enough to diagnose the problem
113-
// so we don't generate a crash dump; those consume disk space after all.)
109+
// On a non-main thread we can't use IPC, so we can't communicate the error message. Just exit.
114110
// Also note that throwing ExitException would only work as intended on the main thread.
111+
#ifdef __native_client__
112+
// Don't abort, to avoid "nacl_loader.exe has stopped working" popup on Windows
113+
_exit(222);
114+
#else
115+
// Trigger a core dump if enabled. Would give us something to work with since the
116+
// error message can't be shown.
115117
std::abort();
118+
#endif
116119
}
117120

118121
#ifdef __native_client__

0 commit comments

Comments
 (0)