Index: src/client/linux/minidump_writer/linux_dumper.cc |
=================================================================== |
--- src/client/linux/minidump_writer/linux_dumper.cc (revision 642) |
+++ src/client/linux/minidump_writer/linux_dumper.cc (working copy) |
@@ -75,6 +75,26 @@ |
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) |
kmixter
2010/08/16 17:21:34
won't this fail to compile on other architectures?
|
+ !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::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() { |