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

Dean Long dlong at openjdk.org
Wed Jul 17 23:47:31 UTC 2024


On Wed, 17 Jul 2024 23:41:54 GMT, Dean Long <dlong 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.
>
> We reset JNIHandleBlock::_top to 0 when exiting the native method frame, so I don't think a local ref wrapped as a jlong is safe to return here, as it will be stale when the caller returns.  You probably need a global ref and manage the lifecycle somehow.

Can this method return jobject instead?  I have similar concerns as @fisk.  I admit I don't really understand how the constant if created or used.

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

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


More information about the hotspot-compiler-dev mailing list