Index: components/nacl/renderer/nexe_load_manager.cc |
diff --git a/components/nacl/renderer/nexe_load_manager.cc b/components/nacl/renderer/nexe_load_manager.cc |
index df70a0608a6bee046e563055917b28da8c13925f..fffcf107f153390520b56d3afe68032f9ba78acc 100644 |
--- a/components/nacl/renderer/nexe_load_manager.cc |
+++ b/components/nacl/renderer/nexe_load_manager.cc |
@@ -89,6 +89,7 @@ NexeLoadManager::NexeLoadManager( |
exit_status_(-1), |
nexe_size_(0), |
plugin_instance_(content::PepperPluginInstance::Get(pp_instance)), |
+ crash_info_shmem_handle_(base::SharedMemory::NULLHandle()), |
weak_factory_(this) { |
SetLastError(""); |
HistogramEnumerateOsArch(GetSandboxArch()); |
@@ -103,6 +104,8 @@ NexeLoadManager::~NexeLoadManager() { |
base::TimeDelta uptime = base::Time::Now() - ready_time_; |
HistogramTimeLarge("NaCl.ModuleUptime.Normal", uptime.InMilliseconds()); |
} |
+ if (base::SharedMemory::IsHandleValid(crash_info_shmem_handle_)) |
+ base::SharedMemory::CloseHandle(crash_info_shmem_handle_); |
} |
void NexeLoadManager::NexeFileDidOpen(int32_t pp_error, |
@@ -231,7 +234,7 @@ void NexeLoadManager::ReportLoadAbort() { |
LogToConsole(error_string); |
} |
-void NexeLoadManager::NexeDidCrash(const char* crash_log) { |
+void NexeLoadManager::NexeDidCrash() { |
VLOG(1) << "Plugin::NexeDidCrash: crash event!"; |
// The NaCl module voluntarily exited. However, this is still a |
// crash from the point of view of Pepper, since PPAPI plugins are |
@@ -259,7 +262,22 @@ void NexeLoadManager::NexeDidCrash(const char* crash_log) { |
// crash log. In the event that this is called twice, the second |
// invocation will just be a no-op, since the entire crash log will |
// have been received and we'll just get an EOF indication. |
- CopyCrashLogToJsConsole(crash_log); |
+ |
+ base::SharedMemory shmem(crash_info_shmem_handle_, true); |
+ if (shmem.Map(kNaClCrashInfoShmemSize)) { |
+ uint32_t crash_log_length; |
+ crash_log_length = *(volatile uint32_t *) shmem.memory(); |
Mark Seaborn
2014/08/18 19:04:09
Nit: this should probably be a C++-style cast
Als
teravest
2014/08/19 19:58:16
Done.
|
+ memcpy(&crash_log_length, shmem.memory(), sizeof(uint32_t)); |
Mark Seaborn
2014/08/18 19:04:09
Redundant -- you forgot to remove this.
teravest
2014/08/19 19:58:16
Removed.
|
+ crash_log_length = std::min<size_t>(crash_log_length, |
+ kNaClCrashInfoMaxLogSize); |
+ |
+ char crash_log_data[kNaClCrashInfoShmemSize]; |
Mark Seaborn
2014/08/18 19:04:09
Let's not allocate this on the stack, since this i
teravest
2014/08/19 19:58:16
Changed to use scoped_ptr<char[]>
|
+ memcpy(crash_log_data, |
+ (char*) shmem.memory() + sizeof(uint32_t), |
Mark Seaborn
2014/08/18 19:04:09
Nit: use C++ cast
teravest
2014/08/19 19:58:16
Done.
|
+ crash_log_length); |
+ std::string crash_log(crash_log_data, crash_log_length); |
+ CopyCrashLogToJsConsole(crash_log); |
+ } |
} |
void NexeLoadManager::set_trusted_plugin_channel( |