Visit invalid roots of only suspended threads
Since this always happens with suspended threads or self, you can
just visit these threads and do not require a suspend all. This
will not miss any roots if the caller was marking a thread root.
Fixes issues like transitioning to suspended and back blocking on a
thread suspension request from another thread. This could cause
deadlocks previously.
Bug: 29062271
Change-Id: I2fef149387aacf0cdc9a773d4f172c42fa53e4dc
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index df81ad1..49f65e1 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -144,6 +144,10 @@
void VisitRoots(RootVisitor* visitor) const
SHARED_REQUIRES(Locks::mutator_lock_);
+ void VisitRootsForSuspendedThreads(RootVisitor* visitor)
+ REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_)
+ SHARED_REQUIRES(Locks::mutator_lock_);
+
// Return a copy of the thread list.
std::list<Thread*> GetList() REQUIRES(Locks::thread_list_lock_) {
return list_;