Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVMTI VThreadMonitorTest fails with an unexpected monitor #16685

Closed
dipak-bagadiya opened this issue Feb 8, 2023 · 7 comments · Fixed by #16844
Closed

JVMTI VThreadMonitorTest fails with an unexpected monitor #16685

dipak-bagadiya opened this issue Feb 8, 2023 · 7 comments · Fixed by #16844

Comments

@dipak-bagadiya
Copy link
Contributor

dipak-bagadiya commented Feb 8, 2023

Issue

The JVMTI VThreadMonitorTest fails with an unexpected monitor from GetCurrentContendedMonitor for a virtual thread.

Test CMD

make test TEST="jtreg:test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadMonitorTest" JTREG="JAVA_OPTIONS=--enable-preview -Dvm.continuations=true;VERBOSE=all"

Test Output:

checkContendedMonitor: VirtualThread-0: contended monitor: (nil)
FAIL: is_vt: 1: unexpected monitor from GetCurrentContendedMonitor
stack trace of current thread:
JVMTI Stack Trace for thread MainThread: frame count: 10
 0: VThreadMonitorTest: checkContendedMonitor(Ljava/lang/Thread;Ljava/lang/Object;Ljava/lang/Object;)V
 1: VThreadMonitorTest: main([Ljava/lang/String;)V
 2: java/lang/invoke/LambdaForm$DMH.0x000000004c014bf0: invokeStatic(Ljava/lang/Object;Ljava/lang/Object;)V
 3: java/lang/invoke/LambdaForm$MH.0x000000004c018a10: invoke(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
 4: java/lang/invoke/LambdaForm$MH.0x000000004c019790: invokeExact_MT(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
 5: jdk/internal/reflect/DirectMethodHandleAccessor: invokeImpl(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
 6: jdk/internal/reflect/DirectMethodHandleAccessor: invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
 7: java/lang/reflect/Method: invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
 8: com/sun/javatest/regtest/agent/MainWrapper$MainThread: run()V
 9: java/lang/Thread: run()V


java.lang.RuntimeException: FAILED status returned from the agent
        at VThreadMonitorTest.main(VThreadMonitorTest.java:142)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:578)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125)
        at java.base/java.lang.Thread.run(Thread.java:1573)
JavaTest Message: Test threw exception: java.lang.RuntimeException: FAILED status returned from the agent
JavaTest Message: shutting down test
@dipak-bagadiya dipak-bagadiya changed the title JVMTI unexpected monitor from GetCurrentContendedMonitor for a vthread VThreadMonitorTest failed with unexpected monitor from GetCurrentContendedMonitor Feb 8, 2023
@dipak-bagadiya dipak-bagadiya changed the title VThreadMonitorTest failed with unexpected monitor from GetCurrentContendedMonitor JVMTI VThreadMonitorTest failed with unexpected monitor from GetCurrentContendedMonitor Feb 8, 2023
@babsingh babsingh changed the title JVMTI VThreadMonitorTest failed with unexpected monitor from GetCurrentContendedMonitor JVMTI VThreadMonitorTest fails with an unexpected monitor Feb 8, 2023
@babsingh babsingh added this to the Java 20 milestone Feb 8, 2023
@fengxue-IS
Copy link
Contributor

@thallium can you take a look at this

@thallium
Copy link
Contributor

In libVThreadMonitorTest.cpp:97 we are expecting the contended monitor to be either lock0 or lock2 but we are getting a null object.

@thallium
Copy link
Contributor

thallium commented Mar 1, 2023

The test also failed for platform thread. We should check the way of triggering contention to see if this is against the spec.

thallium added a commit to thallium/openj9 that referenced this issue Mar 7, 2023
@thallium
Copy link
Contributor

thallium commented Mar 8, 2023

Currently in our code the JVMTI Monitor Contended Enter is triggered before setting the thread flag. When the JVMTI event is triggered, the contended monitor check is then triggered, but at that time we haven't set the flag so we couldn't get the correct monitor object. I've proposed a fix #16844 to set the flag before triggering the event.

@babsingh
Copy link
Contributor

babsingh commented Mar 8, 2023

@thallium Two more tasks before we can close this issue:

  • The test needs to be re-enabled for JDK19 and JDK20; currently, it is disabled; and
  • The fix will also need to be backported to the 0.37 and 0.38 release branches since it impacts all Java versions.

fyi @fengxue-IS @JasonFengJ9 @tajila

@babsingh babsingh reopened this Mar 8, 2023
thallium added a commit to thallium/openj9 that referenced this issue Mar 13, 2023
thallium added a commit to thallium/openj9 that referenced this issue Mar 13, 2023
@thallium
Copy link
Contributor

thallium commented Mar 14, 2023

@thallium Two more tasks before we can close this issue:

  • The test needs to be re-enabled for JDK19 and JDK20; currently, it is disabled; and
  • The fix will also need to be backported to the 0.37 and 0.38 release branches since it impacts all Java versions.

fyi @fengxue-IS @JasonFengJ9 @tajila

Done, see #16895 and adoptium/aqa-tests#4420

@babsingh
Copy link
Contributor

@thallium Thanks. Closing as per #16685 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants