From 4f1a10f84bcfadef263a0890b6834ccd3d5bb52f Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 22 May 2024 12:08:33 +0000 Subject: [PATCH] 8332360: JVM hangs at exit when running on a uniprocessor Reviewed-by: dholmes, dcubed, shade --- src/hotspot/share/runtime/objectMonitor.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index d281acdf006..c80c52e4ba3 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -987,6 +987,13 @@ void ObjectMonitor::ReenterI(JavaThread* current, ObjectWaiter* currentNode) { guarantee(v == ObjectWaiter::TS_ENTER || v == ObjectWaiter::TS_CXQ, "invariant"); assert(owner_raw() != current, "invariant"); + // This thread has been notified so try to reacquire the lock. + if (TryLock(current) == TryLockResult::Success) { + break; + } + + // If that fails, spin again. Note that spin count may be zero so the above TryLock + // is necessary. if (TrySpin(current)) { break; }