[asan] Workaround to avoid hangs in Chromium tests
authorVitaly Buka <vitalybuka@google.com>
Tue, 15 May 2018 01:39:13 +0000 (01:39 +0000)
committerVitaly Buka <vitalybuka@google.com>
Tue, 15 May 2018 01:39:13 +0000 (01:39 +0000)
Summary:
For some reasons on Chromium when we start leak checking we get own pid as 1.
After that we see threads with PPID:0 assuming that thread is dead in infinite
loop.

To resolve particularly this case and possible issues like this, when IsAlive check failed to detect thread status, we need to limit the number of SuspendAllThreads
iterations.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

Differential Revision: https://reviews.llvm.org/D46852

llvm-svn: 332319

compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc

index a6d555e..fe4fe86 100644 (file)
@@ -209,10 +209,10 @@ void ThreadSuspender::KillAllThreads() {
 
 bool ThreadSuspender::SuspendAllThreads() {
   ThreadLister thread_lister(pid_);
-  bool retry;
+  bool retry = true;
   InternalMmapVector<tid_t> threads;
   threads.reserve(128);
-  do {
+  for (int i = 0; i < 30 && retry; ++i) {
     retry = false;
     switch (thread_lister.ListThreads(&threads)) {
       case ThreadLister::Error:
@@ -227,7 +227,7 @@ bool ThreadSuspender::SuspendAllThreads() {
     for (tid_t tid : threads)
       if (SuspendThread(tid))
         retry = true;
-  } while (retry);
+  };
   return suspended_threads_list_.ThreadCount();
 }