diff options
author | thestig@chromium.org <thestig@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-08-14 01:41:39 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-08-14 01:41:39 +0000 |
commit | f5c8f6fb61ce609452361ee9b61a343570f62d12 (patch) | |
tree | 65726ef8d0093bde007ca244fc6ee349b6f23d83 /src/client/linux/minidump_writer/linux_dumper.cc | |
parent | Miscellaneous improvements to minidump-2-core. (diff) | |
download | breakpad-f5c8f6fb61ce609452361ee9b61a343570f62d12.tar.xz |
Fix a couple of bugs where we generate incorrect minidump files on Linux.o
Patch by Markus Gutschke <markus@chromium.org>. R=thestig
Review URL: http://breakpad.appspot.com/150001
Review URL: http://breakpad.appspot.com/155001
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@649 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/linux/minidump_writer/linux_dumper.cc')
-rw-r--r-- | src/client/linux/minidump_writer/linux_dumper.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index c693e907..af479c8d 100644 --- a/src/client/linux/minidump_writer/linux_dumper.cc +++ b/src/client/linux/minidump_writer/linux_dumper.cc @@ -75,6 +75,26 @@ static bool SuspendThread(pid_t pid) { return false; } } +#if defined(__i386) || defined(__x86_64) + // On x86, the stack pointer is NULL or -1, when executing trusted code in + // the seccomp sandbox. Not only does this cause difficulties down the line + // when trying to dump the thread's stack, it also results in the minidumps + // containing information about the trusted threads. This information is + // generally completely meaningless and just pollutes the minidumps. + // We thus test the stack pointer and exclude any threads that are part of + // the seccomp sandbox's trusted code. + user_regs_struct regs; + if (sys_ptrace(PTRACE_GETREGS, pid, NULL, ®s) == -1 || +#if defined(__i386) + !regs.esp +#elif defined(__x86_64) + !regs.rsp +#endif + ) { + sys_ptrace(PTRACE_DETACH, pid, NULL, NULL); + return false; + } +#endif return true; } @@ -111,11 +131,19 @@ bool LinuxDumper::Init() { bool LinuxDumper::ThreadsSuspend() { if (threads_suspended_) return true; - bool good = true; - for (size_t i = 0; i < threads_.size(); ++i) - good &= SuspendThread(threads_[i]); + for (size_t i = 0; i < threads_.size(); ++i) { + if (!SuspendThread(threads_[i])) { + // If the thread either disappeared before we could attach to it, or if + // it was part of the seccomp sandbox's trusted code, it is OK to + // silently drop it from the minidump. + memmove(&threads_[i], &threads_[i+1], + (threads_.size() - i - 1) * sizeof(threads_[i])); + threads_.resize(threads_.size() - 1); + --i; + } + } threads_suspended_ = true; - return good; + return threads_.size() > 0; } bool LinuxDumper::ThreadsResume() { |