commit 0688f184f55cf4e038ed9c34c6a68c364d592c58 Author: Richard Reingruber Date: Fri Jul 11 09:10:01 2025 +0200 Reproduce OOM with duplicate test case diff --git a/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java b/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java index 2e3925a5ca7..0c883655bf5 100644 --- a/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java +++ b/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java @@ -122,6 +122,41 @@ void VThreadBlockedAtOjectWait() throws Exception { } } + /** + * Duplicate of VThreadBlockedAtOjectWait supposed to throw OOM + */ + @Test + void VThreadBlockedAtOjectWait_DUP_FOR_OOM() throws Exception { + var lock = this; + var started = new CountDownLatch(1); + var vthread = Thread.ofVirtual().unstarted(() -> { + started.countDown(); + try { + synchronized (lock) { + while (!done) { + lock.wait(); + } + } + } catch (InterruptedException e) { } + }); + try { + vthread.start(); + + // wait for thread to start and wait + started.await(); + await(vthread, Thread.State.WAITING); + + Path dumpFile = dumpHeap(); + verifyHeapDump(dumpFile); + } finally { + synchronized (lock) { + done = true; + lock.notify(); + } + vthread.join(); + } + } + private Path dumpHeap() throws Exception { Path df = Files.createTempFile(Path.of("."), "dump", ".hprof"); Files.delete(df);