Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions libs/nacl/native_client/src/shared/imc/win/nacl_imc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,27 @@ int NaClWouldBlock() {

int NaClGetLastErrorString(char* buffer, size_t length) {
DWORD error = GetLastError();
return FormatMessageA(
int len = FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buffer,
(DWORD) ((64 * 1024 < length) ? 64 * 1024 : length),
NULL) ? 0 : -1;
NULL);
if (len == 0)
return -1;
if (len > 3) {
if (buffer[len - 1] == '\n')
--len;
if (buffer[len - 1] == '\r')
--len;
if (buffer[len - 1] == '.')
--len;
buffer[len] = '\0';
}
return 0;
}

NaClHandle NaClBoundSocket(const NaClSocketAddress* address) {
Expand Down
6 changes: 6 additions & 0 deletions src/engine/framework/CrashDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

static Log::Logger crashDumpLogs("common.breakpad", "", Log::Level::NOTICE);

static Cvar::Cvar<bool> enableNaclCrashDump("vm.nacl.crashDump", "save NaCl crash dumps", Cvar::NONE, true);

namespace Sys {

static std::string CrashDumpPath() {
Expand All @@ -70,6 +72,10 @@ bool CreateCrashDumpPath() {
// Records a crash dump sent from the VM in minidump format. This is the same
// format that Breakpad uses, but nacl minidump does not require Breakpad to work.
void NaclCrashDump(const std::vector<uint8_t>& dump, Str::StringRef vmName) {
if (!enableNaclCrashDump.Get()) {
Log::Notice("Discarding %s crash dump because NaCl crash dumps are disabled", vmName);
return;
}
const size_t maxDumpSize = (512 + 64) * 1024; // from http://src.chromium.org/viewvc/native_client/trunk/src/native_client/src/untrusted/minidump_generator/minidump_generator.cc
if(dump.size() > maxDumpSize) { // sanity check: shouldn't be bigger than the buffer in nacl
crashDumpLogs.Warn("Ignoring NaCl crash dump request: size too large");
Expand Down
6 changes: 2 additions & 4 deletions src/shared/VMMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "VMMain.h"
#include "CommonProxies.h"
#include "common/IPC/CommonSyscalls.h"
#ifndef _WIN32
#include <unistd.h>
#endif

IPC::Channel VM::rootChannel;

Expand Down Expand Up @@ -145,7 +142,8 @@ NORETURN static void TerminateHandler()
{
if (Sys::OnMainThread()) {
try {
throw; // A terminate handler is only called if there is an active exception
// A terminate handler is only called if there is an active exception
std::rethrow_exception(std::current_exception());
} catch (std::exception& err) {
LogFatalError(Str::Format("Unhandled exception (%s): %s", typeid(err).name(), err.what()));
} catch (...) {
Expand Down