diff options
author | glider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-23 14:39:45 +0000 |
---|---|---|
committer | glider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-23 14:39:45 +0000 |
commit | a83291d61f1e36f773e59303f55de9b3e9599470 (patch) | |
tree | 9f6fd49c92eeb815b9f5cd74f4c3f0985682949d /chrome/browser/crash_handler_host_linux.cc | |
parent | a27065b54c973b8b568e201878fe1fac68e568a8 (diff) | |
download | chromium_src-a83291d61f1e36f773e59303f55de9b3e9599470.zip chromium_src-a83291d61f1e36f773e59303f55de9b3e9599470.tar.gz chromium_src-a83291d61f1e36f773e59303f55de9b3e9599470.tar.bz2 |
Breakpad support for ASan: take 2.
This is an updated version of https://chromiumcodereview.appspot.com/10703116/
which got reverted.
When the code is built with ASan, Chrome should register a callback which notifies the browser about a memory error.
The error report message is passed to the crash handler and is then sent to the crash server along with the minidump.
BUG=143657
Review URL: https://chromiumcodereview.appspot.com/10860006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/crash_handler_host_linux.cc')
-rw-r--r-- | chrome/browser/crash_handler_host_linux.cc | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/chrome/browser/crash_handler_host_linux.cc b/chrome/browser/crash_handler_host_linux.cc index 2e67285..8b6afd973 100644 --- a/chrome/browser/crash_handler_host_linux.cc +++ b/chrome/browser/crash_handler_host_linux.cc @@ -128,7 +128,12 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { // // The message sender is in chrome/app/breakpad_linux.cc. +#if !defined(ADDRESS_SANITIZER) const size_t kIovSize = 8; +#else + const size_t kIovSize = 9; +#endif + struct msghdr msg = {0}; struct iovec iov[kIovSize]; @@ -138,6 +143,9 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { char* guid = new char[kGuidSize + 1]; char* crash_url = new char[kMaxActiveURLSize + 1]; char* distro = new char[kDistroSize + 1]; +#if defined(ADDRESS_SANITIZER) + asan_report_str_ = new char[kMaxAsanReportSize + 1]; +#endif char* tid_buf_addr = NULL; int tid_fd = -1; @@ -151,8 +159,10 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { kDistroSize + 1 + sizeof(tid_buf_addr) + sizeof(tid_fd) + sizeof(uptime) + +#if defined(ADDRESS_SANITIZER) + kMaxAsanReportSize + 1 + +#endif sizeof(oom_size); - iov[0].iov_base = crash_context; iov[0].iov_len = kCrashContextSize; iov[1].iov_base = guid; @@ -169,6 +179,10 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { iov[6].iov_len = sizeof(uptime); iov[7].iov_base = &oom_size; iov[7].iov_len = sizeof(oom_size); +#if defined(ADDRESS_SANITIZER) + iov[8].iov_base = asan_report_str_; + iov[8].iov_len = kMaxAsanReportSize + 1; +#endif msg.msg_iov = iov; msg.msg_iovlen = kIovSize; msg.msg_control = control; @@ -330,6 +344,11 @@ void CrashHandlerHostLinux::OnFileCanReadWithoutBlocking(int fd) { #else info->upload = (getenv(env_vars::kHeadless) == NULL); #endif + +#if defined(ADDRESS_SANITIZER) + info->asan_report_str = asan_report_str_; + info->asan_report_length = strlen(asan_report_str_); +#endif info->process_start_time = uptime; info->oom_size = oom_size; @@ -359,11 +378,25 @@ void CrashHandlerHostLinux::WriteDumpFile(BreakpadInfo* info, dumps_path.value().c_str(), process_type_.c_str(), rand); + if (!google_breakpad::WriteMinidump(minidump_filename.c_str(), crashing_pid, crash_context, kCrashContextSize)) { LOG(ERROR) << "Failed to write crash dump for pid " << crashing_pid; } +#if defined(ADDRESS_SANITIZER) + // Create a temporary file holding the AddressSanitizer report. + const std::string log_filename = + base::StringPrintf("%s/chromium-%s-minidump-%016" PRIx64 ".log", + dumps_path.value().c_str(), + process_type_.c_str(), + rand); + FILE* logfile = fopen(log_filename.c_str(), "w"); + CHECK(logfile); + fprintf(logfile, "%s", asan_report_str_); + fclose(logfile); +#endif + delete[] crash_context; // Freed in CrashDumpTask(); @@ -371,6 +404,13 @@ void CrashHandlerHostLinux::WriteDumpFile(BreakpadInfo* info, minidump_filename.copy(minidump_filename_str, minidump_filename.length()); minidump_filename_str[minidump_filename.length()] = '\0'; info->filename = minidump_filename_str; +#if defined(ADDRESS_SANITIZER) + char* minidump_log_filename_str = new char[minidump_filename.length() + 1]; + minidump_filename.copy(minidump_log_filename_str, minidump_filename.length()); + memcpy(minidump_log_filename_str + minidump_filename.length() - 3, "log", 3); + minidump_log_filename_str[minidump_filename.length()] = '\0'; + info->log_filename = minidump_log_filename_str; +#endif info->pid = crashing_pid; BrowserThread::PostTask( |