RFR: 8345266: java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java JTREG_TEST_THREAD_FACTORY=Virtual fails with OOME [v4]

Patricio Chilano Mateo pchilanomate at openjdk.org
Wed Dec 18 16:21:20 UTC 2024


> Please review this small fix. The call to `Continuation::try_preempt()` can fail and return with a pending OOM exception due to insufficient memory while trying to allocate a new stackChunk. On this particular `OOMEInStampedLock.java` test, the OOM is thrown when returning from Object.wait, which is unexpected and causes the test to fail. But this could also happen when a virtual thread returns from monitorenter, which would cause an assert when coming from compiled code (see `SharedRuntime::monitor_enter_helper()`). Since a failing `try_preempt()` call will just prevent the vthread from being unmounted and force it to follow the normal platform thread code there is no need to throw OOM. The fix is to just clear the pending exception if set, and let future bytecodes handle the OOM condition if still present.
> 
> I verified that test `OOMEInStampedLock.java` now passes with the fix. I also added a new more specific test which fails without this fix and passes with it. I also run the change through mach5 tiers1-3.
> 
> Thanks,
> Patricio

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

  Add Thread.onSpinWait + ensureParallelism

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22780/files
  - new: https://git.openjdk.org/jdk/pull/22780/files/a7f68de3..00c8aeb4

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

  Stats: 11 lines in 1 file changed: 9 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/22780.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22780/head:pull/22780

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


More information about the hotspot-runtime-dev mailing list