summaryrefslogtreecommitdiffstats
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
commit6f7fb43ad37d08ede31a2a49254015caba3abaa0 (patch)
tree77ab50635017a68eec4a16b5bce413dee0491a14
parent8812485d417d56755e3df9aa17a9ddfa2b509f23 (diff)
downloadbcm5719-llvm-6f7fb43ad37d08ede31a2a49254015caba3abaa0.tar.gz
bcm5719-llvm-6f7fb43ad37d08ede31a2a49254015caba3abaa0.zip
[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. llvm-svn: 192295
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
index d63205345cc..163bd45a1be 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ b/compiler-rt/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
OpenPOWER on IntegriCloud