On Wed, 20 Aug 2025 04:58:20 GMT, Leonid Mesnik <lmes...@openjdk.org> wrote:

>> The method
>> get_jvmti_thread_state()
>> should be called only while thread is in vm state.
>> 
>> The post_method_exit is doing some preparation before switching to vm state. 
>> This cause issues if thread is needed to initialize jvmti thread state.
>> 
>> The fix was found using jvmti stress agent and thus no additional regression 
>> test is required.
>
> Leonid Mesnik has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   NULL replaced

I'm very confused by this issue. The description indicates we are calling 
`get_jvmti_thread_state` from the wrong state, but nowhere here or in JBS do I 
see anything showing me the actual failing code path. JBS has a part of a 
hs_err file that reports "# fatal error: LEAF method calling lock? " but I 
don't see how that relates to the stated problem of being in the wrong state ??

Also you state `post_method_exit` is not called when the method terminates via 
an exception, but I can't see that as being the case. The MethodExit callback 
in JVMTI is called under all termination conditions and post_method_exit seems 
similarly unconditional. ??

test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/ExceptionOccurred.java
 line 32:

> 30:  * @run main/othervm/native -agentlib:ExceptionOccurred ExceptionOccurred
> 31:  */
> 32: public class ExceptionOccurred {

I'm very confused by the naming here: what exception has occurred where?

test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/ExceptionOccurred.java
 line 42:

> 40: 
> 41: 
> 42:     // Called from ExcptionExit MethodExit callback via JNI

Suggestion:

    // Called from ExceptionExit MethodExit callback via JNI

test/hotspot/jtreg/serviceability/jvmti/events/MethodExit/ExceptionOccurred/libExceptionOccurred.cpp
 line 32:

> 30: bool method_exit_posted = false;
> 31: static void JNICALL
> 32: cbMethodExit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread, jmethodID 
> method,

Can you add a comment describing the logic of this callback function please. I 
cannot make sense of the logic below. How many times will this callback get 
executed?

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

PR Review: https://git.openjdk.org/jdk/pull/26713#pullrequestreview-3134777503
PR Review Comment: https://git.openjdk.org/jdk/pull/26713#discussion_r2286990333
PR Review Comment: https://git.openjdk.org/jdk/pull/26713#discussion_r2286984860
PR Review Comment: https://git.openjdk.org/jdk/pull/26713#discussion_r2286995606

Reply via email to