On Tue, 23 Jul 2024 06:58:33 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: d3e51daf
Author:    Serguei Spitsyn <sspit...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/d3e51daf7331b84b4e78f7f10360848d7c549c1a
Stats:     7 lines in 2 files changed: 3 ins; 0 del; 4 mod

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

Reviewed-by: dholmes, pchilanomate

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

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

Reply via email to