[compiler-rt] r192295 - [sanitizer] Fix the parent liveness check in StopTheWorld.
Sergey Matveev
earthdok at google.com
Wed Oct 9 06:36:21 PDT 2013
Author: smatveev
Date: Wed Oct 9 08:36:20 2013
New Revision: 192295
URL: http://llvm.org/viewvc/llvm-project?rev=192295&view=rev
Log:
[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.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=192295&r1=192294&r2=192295&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc Wed Oct 9 08:36:20 2013
@@ -185,9 +185,10 @@ static const int kUnblockedSignals[] = {
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 c
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
More information about the llvm-commits
mailing list