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

Erik Österlund eosterlund at openjdk.org
Wed Jul 17 20:50:31 UTC 2024


On Wed, 17 Jul 2024 17:09:46 GMT, Tomáš Zezula <duke at openjdk.org> wrote:

> The `HotSpotJVMCIRuntime#getJObjectValue` method returns a real JNI local handle instead of a JVMCI handle to prevent random crashes on ZGC.

Would you mind explaining on a higher level what this code tries to do? If I understand the fix correctly, we are creating a hotspot JNI local from some Graal constant with getJObjectValue and expose a raw pointer to the HotSpot JNI handle to the caller. Looking at the only use I can find for this API, that raw pointer is then used to create yet another JNI local by calling NewLocalRef in some JNI environment. That seems either redundant, if it's the HotSpot JNI environment (as we just created a JNI local handle), or possibly dangerous if this is some libgraal JNI environment instead, as resolving the JNI local handle is only allowed when the thread is in the in_vm state. Otherwise the reference might become invalid between creating the JNI handle and resolving it in libgraal which is running in_native from HotSpot point of view. What am I missing?

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

PR Comment: https://git.openjdk.org/jdk/pull/20219#issuecomment-2234254581


More information about the hotspot-compiler-dev mailing list