RFR: 8366659: ObjectMonitor::wait() liveness problem with a suspension request [v26]
David Holmes
dholmes at openjdk.org
Tue Jan 20 21:02:13 UTC 2026
On Tue, 20 Jan 2026 20:32:07 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:
>> src/hotspot/share/runtime/objectMonitor.cpp line 1869:
>>
>>> 1867:
>>> 1868: int ret = OS_OK;
>>> 1869: bool was_notified = true;
>>
>> L2021: // Monitor notify has precedence over thread interrupt.
>>
>> With this change to `was_notified` default value, I don't think we can say
>> that monitor notify has precedence over thread interrupt anymore.
>
> I've tracked that comment back to this very old changeset:
>
>
> $ git log 22929fb78f46^!
> commit 22929fb78f4606f726b652a25772980336398575
> Author: Karen Kinnear <acorn at openjdk.org>
> Date: Fri Oct 22 15:59:34 2010 -0400
>
> 6988353: refactor contended sync subsystem
>
> Reduce complexity by factoring synchronizer.cpp
>
> Reviewed-by: dholmes, never, coleenp
I think Dan is right that this has changed the behaviour by deciding `was_notified` earlier in the process. Now this check:
1882 if (interrupted || HAS_PENDING_EXCEPTION) {
1883 was_notified = false;
will supercede the fact we could actually have been notified. And that is a problem because if the current was notified but now throws InterruptedException then we lose the notification. I think my suggestion to set `was_notified` at 1883 was wrong - we need to undo that.
The key point is that if we unlink ourselves then we were definitely not notified; otherwise we must have been.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27040#discussion_r2710053165
More information about the hotspot-runtime-dev
mailing list