summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
diff options
context:
space:
mode:
authorSergey Matveev <earthdok@google.com>2013-10-09 13:36:20 +0000
committerSergey Matveev <earthdok@google.com>2013-10-09 13:36:20 +0000
commitd41fa1b7f2afe5dd78cd4e635e16fd5f079b0318 (patch)
tree77ce43adc4040572f2f8961ae446bc35c68a2558 /lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
parent23a7a43da615bceedefe42b8398b82939e6eeb2d (diff)
[sanitizer] Fix the parent liveness check in StopTheWorld.
Comparing the parent PID with 1 isn't sufficient to ensure the parent is alive, because of prctl(PR_SET_CHILD_SUBREAPER, ...). Compare with the real parent's recorded PID instead. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192295 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
index d63205345..163bd45a1 100644
--- a/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -185,9 +185,10 @@ static const int kUnblockedSignals[] = { SIGABRT, SIGILL, SIGFPE, SIGSEGV,
struct TracerThreadArgument {
StopTheWorldCallback callback;
void *callback_argument;
- // The tracer thread waits on this mutex while the parent finished its
+ // The tracer thread waits on this mutex while the parent finishes its
// preparations.
BlockingMutex mutex;
+ uptr parent_pid;
};
static DieCallbackType old_die_callback;
@@ -226,7 +227,7 @@ static int TracerThread(void* argument) {
internal_prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
// Check if parent is already dead.
- if (internal_getppid() == 1)
+ if (internal_getppid() != tracer_thread_argument->parent_pid)
internal__exit(4);
// Wait for the parent thread to finish preparations.
@@ -370,6 +371,7 @@ void StopTheWorld(StopTheWorldCallback callback, void *argument) {
struct TracerThreadArgument tracer_thread_argument;
tracer_thread_argument.callback = callback;
tracer_thread_argument.callback_argument = argument;
+ tracer_thread_argument.parent_pid = internal_getpid();
const uptr kTracerStackSize = 2 * 1024 * 1024;
ScopedStackSpaceWithGuard tracer_stack(kTracerStackSize);
// Block the execution of TracerThread until after we have set ptrace