RFR: 8334085: Test crash: assert(thread->held_monitor_count() == 0) failed: Must be [v4]

Serguei Spitsyn sspitsyn at openjdk.org
Wed Jul 24 21:43:44 UTC 2024


> The test `serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java` is failing with the assert in the `thaw_internal()` function. The assert is not fully correct as it does not account for an unexpected scenario.
> 
> Thanks to Patricio for reproducing this failure and identifying the root cause:
>> The problem is that we can unmount a virtual thread, then mount it again, thaw a few frames, execute code that acquires a JNI monitor, and then call thaw again without releasing that monitor. In this test this will happen if the vthread is unmounted in System.out.println("Thread doing JNI call: " ...) because of contention with the main thread doing System.out.println("Main waiting for event.").
> The issue can be reproduced by adding Thread.yield() before jniMonitorEnterAndLetObjectDie(). 
> 
> The fix corrects the assert to account for the `thread->jni_monitor_count()`.
> Question: Is the same scenario possible for non-JNI monitors as well?
> Also, the fix includes the test tweak described above which makes this failure always reproducible.
> 
> Testing:
>  - Ran the test `GetOwnedMonitorInfoTest.java` locally
>  - Mach5 tiers 1-6 are passed

Serguei Spitsyn has updated the pull request incrementally with one additional commit since the last revision:

  fixed typo in new comment

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20294/files
  - new: https://git.openjdk.org/jdk/pull/20294/files/fc336bc2..e1dd0169

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

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/20294.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20294/head:pull/20294

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


More information about the serviceability-dev mailing list