mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-21 21:33:07 +00:00
8199012: SEGV in jni_DetachCurrentThread during VM shutdown
Reviewed-by: stuefe, dcubed
This commit is contained in:
parent
d42acfd37b
commit
032ba00a79
@ -4215,25 +4215,26 @@ jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) {
|
||||
|
||||
jint JNICALL jni_DetachCurrentThread(JavaVM *vm) {
|
||||
HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY(vm);
|
||||
VM_Exit::block_if_vm_exited();
|
||||
|
||||
JNIWrapper("DetachCurrentThread");
|
||||
|
||||
// If the thread has already been detached the operation is a no-op
|
||||
if (Thread::current_or_null() == NULL) {
|
||||
HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_OK);
|
||||
HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_OK);
|
||||
return JNI_OK;
|
||||
}
|
||||
|
||||
VM_Exit::block_if_vm_exited();
|
||||
|
||||
JavaThread* thread = JavaThread::current();
|
||||
if (thread->has_last_Java_frame()) {
|
||||
HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN((uint32_t) JNI_ERR);
|
||||
HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN((uint32_t) JNI_ERR);
|
||||
// Can't detach a thread that's running java, that can't work.
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
// Safepoint support. Have to do call-back to safepoint code, if in the
|
||||
// middel of a safepoint operation
|
||||
// middle of a safepoint operation
|
||||
ThreadStateTransition::transition_from_native(thread, _thread_in_vm);
|
||||
|
||||
// XXX: Note that JavaThread::exit() call below removes the guards on the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user