Remove bogus assert in JniAbort.
JniAbort asserts its not in runnable but is inside a ScopedObjectAccess.
Do the right thing wrt the mutator_lock_.
Also adds missing LOCKS_EXCLUDED for thread transitions.
Change-Id: I748efe4d8a82469d0c26ea7b17786820d70436df
diff --git a/src/check_jni.cc b/src/check_jni.cc
index b387f5f..0e521af 100644
--- a/src/check_jni.cc
+++ b/src/check_jni.cc
@@ -55,12 +55,10 @@
if (vm->check_jni_abort_hook != NULL) {
vm->check_jni_abort_hook(vm->check_jni_abort_hook_data, os.str());
} else {
- {
- MutexLock mu(*GlobalSynchronization::thread_suspend_count_lock_);
- CHECK_NE(self->GetState(), kRunnable);
- self->SetState(kNative); // Ensure that we get a native stack trace for this thread.
- }
+ // Ensure that we get a native stack trace for this thread.
+ self->TransitionFromRunnableToSuspended(kNative);
LOG(FATAL) << os.str();
+ self->TransitionFromSuspendedToRunnable(); // Unreachable, keep annotalysis happy.
}
}
diff --git a/src/thread.h b/src/thread.h
index 499527a..13c913f 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -186,15 +186,19 @@
// Called when thread detected that the thread_suspend_count_ was non-zero. Gives up share of
// mutator_lock_ and waits until it is resumed and thread_suspend_count_ is zero.
- void FullSuspendCheck() SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
+ void FullSuspendCheck()
+ LOCKS_EXCLUDED(GlobalSynchronization::thread_suspend_count_lock_)
+ SHARED_LOCKS_REQUIRED(GlobalSynchronization::mutator_lock_);
// Transition from non-runnable to runnable state acquiring share on mutator_lock_.
ThreadState TransitionFromSuspendedToRunnable()
+ LOCKS_EXCLUDED(GlobalSynchronization::thread_suspend_count_lock_)
SHARED_LOCK_FUNCTION(GlobalSynchronization::mutator_lock_);
// Transition from runnable into a state where mutator privileges are denied. Releases share of
// mutator lock.
void TransitionFromRunnableToSuspended(ThreadState new_state)
+ LOCKS_EXCLUDED(GlobalSynchronization::thread_suspend_count_lock_)
UNLOCK_FUNCTION(GlobalSynchronization::mutator_lock_);
// Wait for a debugger suspension on the thread associated with the given peer. Returns the