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 --- runtime/monitor.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'runtime/monitor.cc') diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 4e9e4d946e..3fed8d43b7 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -1005,7 +1005,7 @@ bool Monitor::Deflate(Thread* self, ObjPtr obj) { if (monitor->num_waiters_.load(std::memory_order_relaxed) > 0) { return false; } - if (!monitor->monitor_lock_.ExclusiveTryLock(self)) { + if (!monitor->monitor_lock_.ExclusiveTryLock(self)) { // We cannot deflate a monitor that's currently held. It's unclear whether we should if // we could. return false; @@ -1065,10 +1065,13 @@ void Monitor::InflateThinLocked(Thread* self, Handle obj, LockWo ThreadList* thread_list = Runtime::Current()->GetThreadList(); // Suspend the owner, inflate. First change to blocked and give up mutator_lock_. self->SetMonitorEnterObject(obj.Get()); + bool timed_out; Thread* owner; { ScopedThreadSuspension sts(self, ThreadState::kWaitingForLockInflation); - owner = thread_list->SuspendThreadByThreadId(owner_thread_id, SuspendReason::kInternal); + owner = thread_list->SuspendThreadByThreadId(owner_thread_id, + SuspendReason::kInternal, + &timed_out); } if (owner != nullptr) { // We succeeded in suspending the thread, check the lock's status didn't change. -- cgit v1.2.3-59-g8ed1b