RFR: 8366659: ObjectMonitor::wait() can deadlock with a suspension request [v13]
David Holmes
dholmes at openjdk.org
Thu Nov 20 05:42:02 UTC 2025
On Wed, 19 Nov 2025 22:55:34 GMT, Leonid Mesnik <lmesnik at openjdk.org> wrote:
>> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8366659: Refactored tests.
>
> Changes requested by lmesnik (Reviewer).
@lmesnik are the JVMTI thread state transitions performed in the event posting code? If so the different order, and thus different states, would be a concern. That said we have noticed that only the timeout case seems to operate in a way that the monitor reentry can post contended_enter and contended_entered events, which seems very odd in itself. Though I will also note that the way the suspension code drops and then re-acquires the monitor, any contended_enter* events could get posted multiple times which would also be surprising.
Maintaining the event order is problematic as, with the fix to the deadlock issue, we only allow suspension during reentry, and that would mean the `monitor_waited` event would be posted whilst the thread is still suspended. To be clear(er) in the old code we would do:
wait -> suspend if needed -> resumed -> post monitor_waited -> renter monitor
whereas the new code, if we kept the placement of the event, would do
wait -> post monitor_waited -> reenter monitor -> suspend if needed and drop monitor -> resumed -> reenter monitor
and what the proposed code actually does is
wait -> reenter monitor -> suspend if needed and drop monitor -> resumed -> reenter monitor -> post monitor_waited
Given the lack of specificity in the JVM TI spec around these different events I think any assumptions in a TCK test could be challenged, but it would still be a change in behaviour.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27040#issuecomment-3555943800
More information about the serviceability-dev
mailing list