diff options
| author | 2014-09-17 22:24:31 +0000 | |
|---|---|---|
| committer | 2014-09-17 22:24:31 +0000 | |
| commit | e70547c69a4428e32b7182386a6de166e5b3d22b (patch) | |
| tree | b102a67b259f2b9f5fe40e3a163f3135bdaf6466 | |
| parent | cbd49ac468a70808a5c66ed4f04c80bc486dafce (diff) | |
| parent | a2af5c7e3262bb7165e9320426bd6925f1a3c90d (diff) | |
Merge "Only log an error if an unattached thread is unregistered."
| -rw-r--r-- | runtime/thread_list.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 2dbfb3ebc7..08e66ea61d 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -872,14 +872,21 @@ 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)); - Locks::thread_suspend_count_lock_->ExclusiveLock(self); - bool removed = false; - if (!self->IsSuspended()) { - list_.remove(self); - removed = true; + bool removed = true; + if (!Contains(self)) { + std::ostringstream os; + DumpNativeStack(os, GetTid(), " native: ", nullptr); + LOG(ERROR) << "Request to unregister unattached thread\n" << os.str(); + } else { + Locks::thread_suspend_count_lock_->ExclusiveLock(self); + if (!self->IsSuspended()) { + list_.remove(self); + } else { + // We failed to remove the thread due to a suspend request, loop and try again. + removed = false; + } + Locks::thread_suspend_count_lock_->ExclusiveUnlock(self); } - Locks::thread_suspend_count_lock_->ExclusiveUnlock(self); Locks::thread_list_lock_->ExclusiveUnlock(self); if (removed) { delete self; |