RFR: 8366659: ObjectMonitor::wait() can deadlock with a suspension request [v6]
Anton Artemov
aartemov at openjdk.org
Fri Nov 14 12:04:36 UTC 2025
On Thu, 13 Nov 2025 19:13:39 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:
>> Anton Artemov has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 20 commits:
>>
>> - Merge remote-tracking branch 'origin/master' into JDK-8366659-OM-wait-suspend-deadlock
>> - 8366659: Fixed lines in tests.
>> - Merge remote-tracking branch 'origin/master' into JDK-8366659-OM-wait-suspend-deadlock
>> - 8366659: Added a comment to a boolean arg for enter()
>> - Merge remote-tracking branch 'origin/master' into JDK-8366659-OM-wait-suspend-deadlock
>> - Merge remote-tracking branch 'origin/master' into JDK-8366659-OM-wait-suspend-deadlock
>> - 8366659: Fixed new lines.
>> - Merge remote-tracking branch 'origin/master' into JDK-8366659-OM-wait-suspend-deadlock
>> - 8366659: Removed incorrect assert,
>> - 8366659: Fixed merge conflict
>> - ... and 10 more: https://git.openjdk.org/jdk/compare/400a83da...702880c6
>
> test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/SuspendWithObjectMonitorWait.java line 428:
>
>> 426: // launch the waiter thread
>> 427: synchronized (barrierLaunch) {
>> 428: waiter = new SuspendWithObjectMonitorWaitWorker("waiter", 1);
>
> We should increase this timeout to minimize the chance of it happening between the main thread acquiring the `threadLock` and issuing the notification, in which case the waiter will not go through `reenter_internal` but through `enter`. Also it avoids some funny scheduling where the main thread never acquires the `threadLock`.
Done.
> test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/SuspendWithObjectMonitorWait.java line 466:
>
>> 464: testState = TS_READY_TO_NOTIFY;
>> 465: threadLock.notify();
>> 466:
>
> We should add a `Thread.sleep` here to give time for the wait to timeout before suspending the waiter thread. Should be more than what the waiter thread is using as timeout. I have tested a timeout value of 100ms and here sleeping 200ms and always see the deadlock on `reenter_internal` (with current mainline code).
Removed the sleep which was not needed and added another one with 200ms as suggested.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27040#discussion_r2527251981
PR Review Comment: https://git.openjdk.org/jdk/pull/27040#discussion_r2527248616
More information about the serviceability-dev
mailing list