RFR (S): 8238676: jni crashes on accessing it from process exit hook
gerard ziemski
gerard.ziemski at oracle.com
Tue Feb 25 16:45:24 UTC 2020
hi David,
On 2/18/20 8:04 PM, David Holmes wrote:
> Bug: https://bugs.openjdk.java.net/browse/JDK-8238676
> webrev: http://cr.openjdk.java.net/~dholmes/8238676/webrev/
>
> If an application tries to use JNI from an atexit handler, the attempt
> can't succeed (the VM has already logically terminated) but it should
> not crash. The JNI Invocation API code was missing some checks in
> places and wasn't aware of the possibility of trying to make calls
> from the VMThread.
>
> Testing:
> - new test added for the JNI Invocation API
> - tiers 1-3
>
> Thanks,
> David
In jni_GetEnv() we have:
4120 if (vm_created == 0) {
4121 *penv = NULL;
4122 ret = JNI_EDETACHED;
4123 return ret;
4124 }
but in jni_DetachCurrentThread() we have:
4063 if (vm_created == 0) {
4064 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_ERR);
4065 return JNI_ERR;
4066 }
should lines 4064,4065 perhaps be:
4064 HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_EDETACHED);
4065 return JNI_EDETACHED;
to be consistent?
Looks good otherwise.
cheers
More information about the hotspot-runtime-dev
mailing list