Commit 394ed8e2 authored by bsy@google.com's avatar bsy@google.com

Ensure that errors that occur during load will get crash log info to JS console

Tested this by running Duke Nukem w/i NaClBox with
http://codereview.chromium.org/10823018/ patched into native_client,
using the command line:

bash -c 'ulimit -v 1000000;  /mm/bsy/chromium/chromium64.git0/src/out/Release/chrome --user-data-dir=/tmp/udd'

to verify that the crash log shows up.

BUG= http://code.google.com/p/nativeclient/issues/detail?id=2776
TEST= Manual.


Review URL: https://chromiumcodereview.appspot.com/10823019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148470 0039d316-1c4b-4281-b951-d872f2087c98
parent dbc761a8
...@@ -614,7 +614,8 @@ bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper, ...@@ -614,7 +614,8 @@ bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
bool service_runtime_started = bool service_runtime_started =
new_service_runtime->Start(wrapper, new_service_runtime->Start(wrapper,
error_info, error_info,
manifest_base_url()); manifest_base_url(),
crash_cb);
PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n", PLUGIN_PRINTF(("Plugin::LoadNaClModuleCommon (service_runtime_started=%d)\n",
service_runtime_started)); service_runtime_started));
if (!service_runtime_started) { if (!service_runtime_started) {
...@@ -1146,7 +1147,7 @@ void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { ...@@ -1146,7 +1147,7 @@ void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) {
NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); NaClLog(4, "Leaving NexeFileDidOpenContinuation\n");
} }
static void LogLineToConsole(Plugin* plugin, nacl::string one_line) { static void LogLineToConsole(Plugin* plugin, const nacl::string& one_line) {
PLUGIN_PRINTF(("LogLineToConsole: %s\n", PLUGIN_PRINTF(("LogLineToConsole: %s\n",
one_line.c_str())); one_line.c_str()));
plugin->AddToConsole(one_line); plugin->AddToConsole(one_line);
...@@ -1192,18 +1193,26 @@ void Plugin::NexeDidCrash(int32_t pp_error) { ...@@ -1192,18 +1193,26 @@ void Plugin::NexeDidCrash(int32_t pp_error) {
if (nexe_error_reported()) { if (nexe_error_reported()) {
PLUGIN_PRINTF(("Plugin::NexeDidCrash: error already reported;" PLUGIN_PRINTF(("Plugin::NexeDidCrash: error already reported;"
" suppressing\n")); " suppressing\n"));
return; } else {
}
if (nacl_ready_state() == DONE) { if (nacl_ready_state() == DONE) {
ReportDeadNexe(); ReportDeadNexe();
} else { } else {
ErrorInfo error_info; ErrorInfo error_info;
error_info.SetReport(ERROR_START_PROXY_CRASH, // Not quite right. // The error is not quite right. In particular, the crash
// reported by this path could be due to NaCl application
// crashes that occur after the pepper proxy has started.
error_info.SetReport(ERROR_START_PROXY_CRASH,
"Nexe crashed during startup"); "Nexe crashed during startup");
ReportLoadError(error_info); ReportLoadError(error_info);
} }
}
// In all cases, try to grab the crash log. The first error
// reported may have come from the start_module RPC reply indicating
// a validation error or something similar, which wouldn't grab the
// crash log. In the event that this is called twice, the second
// invocation will just be a no-op, since all the crash log will
// have been received and we'll just get an EOF indication.
CopyCrashLogToJsConsole(); CopyCrashLogToJsConsole();
} }
......
...@@ -588,6 +588,8 @@ bool ServiceRuntime::InitCommunication(nacl::DescWrapper* nacl_desc, ...@@ -588,6 +588,8 @@ bool ServiceRuntime::InitCommunication(nacl::DescWrapper* nacl_desc,
return false; return false;
} }
out_conn_cap = NULL; // ownership passed out_conn_cap = NULL; // ownership passed
PLUGIN_PRINTF(("ServiceRuntime::InitCommunication"
" starting reverse service\n"));
reverse_service_ = new nacl::ReverseService(conn_cap, rev_interface_->Ref()); reverse_service_ = new nacl::ReverseService(conn_cap, rev_interface_->Ref());
if (!reverse_service_->Start()) { if (!reverse_service_->Start()) {
error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE, error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE,
...@@ -624,7 +626,8 @@ bool ServiceRuntime::InitCommunication(nacl::DescWrapper* nacl_desc, ...@@ -624,7 +626,8 @@ bool ServiceRuntime::InitCommunication(nacl::DescWrapper* nacl_desc,
} }
bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc, bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc,
ErrorInfo* error_info, const nacl::string& url) { ErrorInfo* error_info, const nacl::string& url,
pp::CompletionCallback crash_cb) {
PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n", PLUGIN_PRINTF(("ServiceRuntime::Start (nacl_desc=%p)\n",
reinterpret_cast<void*>(nacl_desc))); reinterpret_cast<void*>(nacl_desc)));
...@@ -655,7 +658,22 @@ bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc, ...@@ -655,7 +658,22 @@ bool ServiceRuntime::Start(nacl::DescWrapper* nacl_desc,
subprocess_.reset(tmp_subprocess.release()); subprocess_.reset(tmp_subprocess.release());
if (!InitCommunication(nacl_desc, error_info)) { if (!InitCommunication(nacl_desc, error_info)) {
subprocess_.reset(NULL); // On a load failure the service runtime does not crash itself to
// avoid a race where the no-more-senders error on the reverse
// channel esrvice thread might cause the crash-detection logic to
// kick in before the start_module RPC reply has been received. So
// we induce a service runtime crash here. We do not release
// subprocess_ since it's needed to collect crash log output after
// the error is reported.
Log(LOG_FATAL, "reap logs");
if (NULL == reverse_service_) {
// No crash detector thread.
PLUGIN_PRINTF(("scheduling to get crash log\n"));
pp::Module::Get()->core()->CallOnMainThread(0, crash_cb, PP_OK);
PLUGIN_PRINTF(("should fire soon\n"));
} else {
PLUGIN_PRINTF(("Reverse service thread will pick up crash log\n"));
}
return false; return false;
} }
......
...@@ -219,7 +219,8 @@ class ServiceRuntime { ...@@ -219,7 +219,8 @@ class ServiceRuntime {
// describing the error. // describing the error.
bool Start(nacl::DescWrapper* nacl_file_desc, bool Start(nacl::DescWrapper* nacl_file_desc,
ErrorInfo* error_info, ErrorInfo* error_info,
const nacl::string& url); const nacl::string& url,
pp::CompletionCallback crash_cb);
// Starts the application channel to the nexe. // Starts the application channel to the nexe.
SrpcClient* SetupAppChannel(); SrpcClient* SetupAppChannel();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment