Only log an error if an unattached thread is unregistered.
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
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index fc687dc..9a58942 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -833,13 +833,19 @@
// 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);
}