diff options
| author | Sergey Matveev <earthdok@google.com> | 2013-10-08 18:01:03 +0000 |
|---|---|---|
| committer | Sergey Matveev <earthdok@google.com> | 2013-10-08 18:01:03 +0000 |
| commit | adef7542974a0c576b6ef166475bedd772477452 (patch) | |
| tree | 695adc594402a2f293420fb5ca6bb1158ca4f03c | |
| parent | b32b1be766f04a3b378b2e685748bd8eb05ac6ed (diff) | |
| download | bcm5719-llvm-adef7542974a0c576b6ef166475bedd772477452.tar.gz bcm5719-llvm-adef7542974a0c576b6ef166475bedd772477452.zip | |
[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.
llvm-svn: 192210
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc | 5 |
1 files changed, 5 insertions, 0 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 3c650be5c57..d63205345cc 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc @@ -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(); |

