OSDN Git Service

Only log an error if an unattached thread is unregistered.
authorIan Rogers <irogers@google.com>
Mon, 15 Sep 2014 22:17:07 +0000 (15:17 -0700)
committerIan Rogers <irogers@google.com>
Mon, 15 Sep 2014 22:17:07 +0000 (15:17 -0700)
Turn a fatal check into a diagnostic error. It looks like this issue arises
when a runtime shutsdown without properly being started.
Bug: 17011539

Change-Id: I2983c8332e83769e9480e8f30a46ca3b80a2e90e

runtime/thread_list.cc

index fc687dc..9a58942 100644 (file)
@@ -833,13 +833,19 @@ void ThreadList::Unregister(Thread* self) {
     // thread_suspend_count_lock_ so that the unregistering thread cannot be suspended.
     // Note: deliberately not using MutexLock that could hold a stale self pointer.
     Locks::thread_list_lock_->ExclusiveLock(self);
-    CHECK(Contains(self));
-    // Note: we don't take the thread_suspend_count_lock_ here as to be suspending a thread other
-    // than yourself you need to hold the thread_list_lock_ (see Thread::ModifySuspendCount).
-    if (!self->IsSuspended()) {
-      list_.remove(self);
-      delete self;
+    if (!Contains(self)) {
+      std::ostringstream os;
+      DumpNativeStack(os, GetTid(), "  native: ", nullptr);
+      LOG(ERROR) << "Request to unregister unattached thread\n" << os.str();
       self = nullptr;
+    } else {
+      // Note: we don't take the thread_suspend_count_lock_ here as to be suspending a thread other
+      // than yourself you need to hold the thread_list_lock_ (see Thread::ModifySuspendCount).
+      if (!self->IsSuspended()) {
+        list_.remove(self);
+        delete self;
+        self = nullptr;
+      }
     }
     Locks::thread_list_lock_->ExclusiveUnlock(self);
   }