RFR: 8336663: [JVMCI] VM Crash on ZGC due to incompatible handle returned by HotSpotJVMCIRuntime#getJObjectValue [v2]

Tomáš Zezula duke at openjdk.org
Fri Jul 19 13:51:34 UTC 2024


On Thu, 18 Jul 2024 08:36:16 GMT, Tomáš Zezula <duke at openjdk.org> wrote:

>> src/hotspot/share/jvmci/jvmciCompilerToVM.cpp line 715:
>> 
>>> 713:     JVMCIObject constant = JVMCIENV->wrap(constant_jobject);
>>> 714:     Handle constant_value = JVMCIENV->asConstant(constant, JVMCI_CHECK_0);
>>> 715:     jobject jni_handle = JNIHandles::make_local(THREAD, constant_value());
>> 
>> Who is responsible for cleaning up these local refs?  My recollection is that they are allocated in the top most containing scope but if you haven't introduced new JNI scope they will never get released.
>
> @tkrodriguez The Truffle shared library compiler is always invoked from Java code by calling a native method. The JNI local reference is allocated within the JNI locals frame of the native method. When the method ends, this frame is removed, and the handle is cleared.
> 
> For host method compilation, where the caller thread lacks a Java frame anchor, a new JNI local frame is pushed, which is subsequently popped at the end of the method. In this case, the handle is cleared by the `PopLocalFrame`.

The `getJObjectValue` Javadoc has beed improved to explain how the returned JNI handle is scoped.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20219#discussion_r1684413724


More information about the hotspot-compiler-dev mailing list