RFR: 8366659: ObjectMonitor::wait() can deadlock with a suspension request [v6]
Anton Artemov
aartemov at openjdk.org
Fri Nov 14 12:04:30 UTC 2025
On Thu, 13 Nov 2025 20:50:57 GMT, Daniel D. Daugherty <dcubed 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
>
> So the bug report talks about two different deadlocks and we have added two new test cases to SuspendWithObjectMonitorWait.java.
>
> I think the new `doWork2` test case is added to catch deadlock-1 when we have a suspended
> thread made the successor over and over again so that none of the other contending threads
> ever get the monitor even though it is unlocked.
>
> I think the new `doWork3` test case is added to catch deadlock-2 where the waiting thread
> manages to re-enter the monitor and then gets suspended while on its way back to Java.
>
> @toxaart and/or @pchilano - Please verify my understanding of this mapping from the two
> new test cases to the two deadlocks. Thanks!
Thanks @dcubed-ojdk and @pchilano, I addressed all the points. The diagrams are now added to the test.
> test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/SuspendWithObjectMonitorWait.java line 110:
>
>> 108:
>> 109: public static void main(String[] args) throws Exception {
>> 110: int test = Integer.parseInt(args[0]);
>
> I think this will throw if the test is called without any parameters.
>
> Also, the `usage` function needs to be updated to reflect the addition of the
> test number parameter.
Addressed in the latest commit.
> test/hotspot/jtreg/serviceability/jvmti/SuspendWithObjectMonitorWait/SuspendWithObjectMonitorWait.java line 297:
>
>> 295: }
>> 296:
>> 297: // Notify the resumer while holding the threadLock
>
> Nit: please add a period at the end of this sentence.
Addressed in the latest commit.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27040#issuecomment-3532412149
PR Review Comment: https://git.openjdk.org/jdk/pull/27040#discussion_r2527249217
PR Review Comment: https://git.openjdk.org/jdk/pull/27040#discussion_r2527245664
More information about the serviceability-dev
mailing list