RFR: 8373120: Virtual thread stuck in BLOCKED state [v3]

Patricio Chilano Mateo pchilanomate at openjdk.org
Tue Jan 20 20:46:04 UTC 2026


> Please review the following patch. This fixes a bug in how we handle state changes for the timed `Object.wait` case in `afterYield`, which can leave a virtual thread stuck in the `BLOCKED` state. It can be triggered by two consecutive calls to timed `Object.wait`, if the first call receives a notification and the second call relies on the timeout task to wake up the thread. I added the full sequence of events that leads to the vthread getting stuck in JBS.
> 
> The fix is to check for `notified` and attempt to change the state to `BLOCKED` inside the synchronized block. This guarantees that we don't change the state of an already new timed `Object.wait` call.
> 
> The PR includes a new test which reproduces the issue when run several times in mach5. It's a hybrid of my original repro test and another one created by @AlanBateman.
> 
> Thanks,
> Patricio

Patricio Chilano Mateo has updated the pull request incrementally with one additional commit since the last revision:

  Randomly choose platform or virtual notifier

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/29255/files
  - new: https://git.openjdk.org/jdk/pull/29255/files/b69a40f1..c31f41fa

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29255&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29255&range=01-02

  Stats: 15 lines in 1 file changed: 7 ins; 0 del; 8 mod
  Patch: https://git.openjdk.org/jdk/pull/29255.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29255/head:pull/29255

PR: https://git.openjdk.org/jdk/pull/29255


More information about the core-libs-dev mailing list