From 8bc6a58df7046b4d6f4b51eb274c7e60fea396ff Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Tue, 19 Dec 2023 18:48:15 +0000 Subject: Revert^17 "Thread suspension cleanup and deadlock fix" This reverts commit c6371b52df0da31acc174a3526274417b7aac0a7. Reason for revert: This seems to have two remaining issues: 1. The second DCHECK in WaitForFlipFunction is not completely guaranteed to hold, resulting in failures for 658-fp-read-barrier. 2. WaitForSuspendBarrier seems to time out occasionally, possibly spuriously so. We fail when the futex times out once. That's probably incompatible with the app freezer. We should retry a few times. Change-Id: Ibd8909b31083fc29e6d4f1fcde003d08eb16fc0a --- openjdkjvmti/ti_threadgroup.cc | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'openjdkjvmti/ti_threadgroup.cc') diff --git a/openjdkjvmti/ti_threadgroup.cc b/openjdkjvmti/ti_threadgroup.cc index bfe6b51791..120024e8b2 100644 --- a/openjdkjvmti/ti_threadgroup.cc +++ b/openjdkjvmti/ti_threadgroup.cc @@ -171,26 +171,18 @@ static void GetThreads(art::Handle thread_group, CHECK(thread_group != nullptr); art::MutexLock mu(art::Thread::Current(), *art::Locks::thread_list_lock_); - std::list thread_list = art::Runtime::Current()->GetThreadList()->GetList(); - // We have to be careful with threads exiting while we build this list. - std::vector tefs(thread_list.size()); - auto i = tefs.begin(); - for (art::Thread* thd : thread_list) { - thd->NotifyOnThreadExit(&*i++); - } - DCHECK(i == tefs.end()); - - i = tefs.begin(); - for (art::Thread* t : thread_list) { - art::ThreadExitFlag* tef = &*i++; - art::ObjPtr peer = t->LockedGetPeerFromOtherThread(tef); - if (peer != nullptr && !tef->HasExited() && !t->IsStillStarting() && - IsInDesiredThreadGroup(thread_group, peer)) { + for (art::Thread* t : art::Runtime::Current()->GetThreadList()->GetList()) { + if (t->IsStillStarting()) { + continue; + } + art::ObjPtr peer = t->GetPeerFromOtherThread(); + if (peer == nullptr) { + continue; + } + if (IsInDesiredThreadGroup(thread_group, peer)) { thread_peers->push_back(peer); } - t->UnregisterThreadExitFlag(tef); } - DCHECK(i == tefs.end()); } static void GetChildThreadGroups(art::Handle thread_group, -- cgit v1.2.3-59-g8ed1b