[PATCH] [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.

Sergey Matveev earthdok at google.com
Tue Oct 8 08:58:32 PDT 2013


Hi dvyukov,

http://llvm-reviews.chandlerc.com/D1859

Files:
  lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc

Index: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -224,6 +224,11 @@
   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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1859.1.patch
Type: text/x-patch
Size: 673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131008/20e98e4c/attachment.bin>


More information about the llvm-commits mailing list