[compiler-rt] r192210 - [sanitizer] Fix deadlock in StopTheWorld.

Sergey Matveev earthdok at google.com
Tue Oct 8 11:01:03 PDT 2013


Author: smatveev
Date: Tue Oct  8 13:01:03 2013
New Revision: 192210

URL: http://llvm.org/viewvc/llvm-project?rev=192210&view=rev
Log:
[sanitizer] Fix deadlock in StopTheWorld.

The tracer thread in StopTheWorld could wait on a mutex forever if the parent
process died before unlocking it. Use PR_SET_PDEATHSIG so that the parent would
kill the child in this scenario.

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=192210&r1=192209&r2=192210&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 Tue Oct  8 13:01:03 2013
@@ -224,6 +224,11 @@ static int TracerThread(void* argument)
   TracerThreadArgument *tracer_thread_argument =
       (TracerThreadArgument *)argument;
 
+  internal_prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
+  // Check if parent is already dead.
+  if (internal_getppid() == 1)
+    internal__exit(4);
+
   // Wait for the parent thread to finish preparations.
   tracer_thread_argument->mutex.Lock();
   tracer_thread_argument->mutex.Unlock();





More information about the llvm-commits mailing list