From 70f3469310f385c4953a9069ca99e0806bc6ef5b Mon Sep 17 00:00:00 2001 From: Anton Artemov Date: Wed, 20 Aug 2025 08:13:07 +0000 Subject: [PATCH] 8365556: ObjectMonitor::try_lock_or_add_to_entry_list() returns true with the wrong state of the node Reviewed-by: pchilanomate, dholmes, fbredberg --- src/hotspot/share/runtime/objectMonitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index ceac0b42acf..39ba328b0d0 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -711,6 +711,7 @@ void ObjectMonitor::add_to_entry_list(JavaThread* current, ObjectWaiter* node) { // if we added current to _entry_list. Once on _entry_list, current // stays on-queue until it acquires the lock. bool ObjectMonitor::try_lock_or_add_to_entry_list(JavaThread* current, ObjectWaiter* node) { + assert(node->TState == ObjectWaiter::TS_RUN, ""); node->_prev = nullptr; node->TState = ObjectWaiter::TS_ENTER; @@ -726,6 +727,7 @@ bool ObjectMonitor::try_lock_or_add_to_entry_list(JavaThread* current, ObjectWai if (try_lock(current) == TryLockResult::Success) { assert(!has_successor(current), "invariant"); assert(has_owner(current), "invariant"); + node->TState = ObjectWaiter::TS_RUN; return true; } }