On Sat, 9 Aug 2025 20:30:14 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. src/hotspot/share/prims/jvmtiExport.cpp line 1839: > 1837: JRT_BLOCK > 1838: state = get_jvmti_thread_state(thread); > 1839: JRT_BLOCK_END The `JRT_BLOCK` is defined as: #define JRT_BLOCK \ { \ assert(current == JavaThread::current(), "Must be"); \ ThreadInVMfromJava __tiv(current); \ JavaThread* THREAD = current; /* For exception macros. */ \ DEBUG_ONLY(VMEntryWrapper __vew;) I'd suggest something like this instead of using `JRT_BLOCK`: - JvmtiThreadState *state = get_jvmti_thread_state(thread); + JvmtiThreadState *state = nullptr; + { + ThreadInVMfromJava __tiv(thread); + state = get_jvmti_thread_state(thread); + } Alternatively, the `JRT_BLOCK` can be started at the line 1837 and ended with `JRT_BLOCK_END` at the line 1875. Not sure, what issue we can encounter with this though. At least, it is worth a try. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26713#discussion_r2272164623