OSDN Git Service

ART: Avoid recursive abort in barrier
authorAndreas Gampe <agampe@google.com>
Mon, 22 Jun 2015 17:04:39 +0000 (10:04 -0700)
committerAndreas Gampe <agampe@google.com>
Mon, 22 Jun 2015 17:04:39 +0000 (10:04 -0700)
Try to avoid recursive abort in barrier. May lead to a segfault
instead of a nested abort in bad cases.

Change-Id: I0e7976b77c243956dbcf81142bd5df81d5927ce0

runtime/barrier.cc

index d21f551..0d842cc 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "barrier.h"
 
+#include "base/logging.h"
 #include "base/mutex.h"
 #include "base/time_utils.h"
 #include "thread.h"
@@ -87,7 +88,14 @@ void Barrier::SetCountLocked(Thread* self, int count) {
 }
 
 Barrier::~Barrier() {
-  CHECK_EQ(count_, 0) << "Attempted to destroy barrier with non zero count";
+  if (gAborting == 0) {
+    // Only check when not aborting.
+    CHECK_EQ(count_, 0) << "Attempted to destroy barrier with non zero count";
+  } else {
+    if (count_ != 0) {
+      LOG(WARNING) << "Attempted to destroy barrier with non zero count " << count_;
+    }
+  }
 }
 
 }  // namespace art