Skip to content

Commit 824dbfb

Browse files
fthevenetgnu-andrew
authored andcommitted
8186199: [windows] JNI_DestroyJavaVM not covered by SEH
Reviewed-by: andrew, stuefe Backport-of: 14d898a
1 parent 5e70a86 commit 824dbfb

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

hotspot/src/share/vm/prims/jni.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5296,7 +5296,7 @@ static jint JNI_CreateJavaVM_inner(JavaVM **vm, void **penv, void *args) {
52965296
}
52975297
52985298
_JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) {
5299-
jint result = 0;
5299+
jint result = JNI_ERR;
53005300
// On Windows, let CreateJavaVM run with SEH protection
53015301
#ifdef _WIN32
53025302
__try {
@@ -5350,12 +5350,11 @@ DT_RETURN_MARK_DECL(DestroyJavaVM, jint
53505350
, HOTSPOT_JNI_DESTROYJAVAVM_RETURN(_ret_ref));
53515351
#endif /* USDT2 */
53525352
5353-
jint JNICALL jni_DestroyJavaVM(JavaVM *vm) {
5353+
static jint JNICALL jni_DestroyJavaVM_inner(JavaVM *vm) {
53545354
#ifndef USDT2
53555355
DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm);
53565356
#else /* USDT2 */
5357-
HOTSPOT_JNI_DESTROYJAVAVM_ENTRY(
5358-
vm);
5357+
HOTSPOT_JNI_DESTROYJAVAVM_ENTRY(vm);
53595358
#endif /* USDT2 */
53605359
jint res = JNI_ERR;
53615360
DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res);
@@ -5391,6 +5390,20 @@ jint JNICALL jni_DestroyJavaVM(JavaVM *vm) {
53915390
}
53925391
}
53935392
5393+
jint JNICALL jni_DestroyJavaVM(JavaVM *vm) {
5394+
jint result = JNI_ERR;
5395+
// On Windows, we need SEH protection
5396+
#ifdef _WIN32
5397+
__try {
5398+
#endif
5399+
result = jni_DestroyJavaVM_inner(vm);
5400+
#ifdef _WIN32
5401+
} __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
5402+
// Nothing to do.
5403+
}
5404+
#endif
5405+
return result;
5406+
}
53945407
53955408
static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool daemon) {
53965409
JavaVMAttachArgs *args = (JavaVMAttachArgs *) _args;

0 commit comments

Comments
 (0)