mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-08 22:19:18 +00:00
8074860: Structured Exception Catcher missing around CreateJavaVM on Windows
Add __try/__except around JNI_CreateJavaVM Reviewed-by: mgronlun, dcubed
This commit is contained in:
parent
8c232f54a5
commit
704c02a180
@ -379,15 +379,6 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void VM_Version::get_cpu_info_wrapper() {
|
||||
get_cpu_info_stub(&_cpuid_info);
|
||||
}
|
||||
|
||||
#ifndef CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED
|
||||
#define CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(f) f()
|
||||
#endif
|
||||
|
||||
void VM_Version::get_processor_features() {
|
||||
|
||||
_cpu = 4; // 486 by default
|
||||
@ -401,9 +392,7 @@ void VM_Version::get_processor_features() {
|
||||
if (!Use486InstrsOnly) {
|
||||
// Get raw processor info
|
||||
|
||||
// Some platforms (like Win*) need a wrapper around here
|
||||
// in order to properly handle SEGV for YMM registers test.
|
||||
CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(get_cpu_info_wrapper);
|
||||
get_cpu_info_stub(&_cpuid_info);
|
||||
|
||||
assert_is_initialized();
|
||||
_cpu = extended_cpu_family();
|
||||
|
||||
@ -2695,17 +2695,6 @@ address os::win32::fast_jni_accessor_wrapper(BasicType type) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void os::win32::call_test_func_with_wrapper(void (*funcPtr)(void)) {
|
||||
// Install a win32 structured exception handler around the test
|
||||
// function call so the VM can generate an error dump if needed.
|
||||
__try {
|
||||
(*funcPtr)();
|
||||
} __except(topLevelExceptionFilter(
|
||||
(_EXCEPTION_POINTERS*)_exception_info())) {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
|
||||
// Virtual Memory
|
||||
|
||||
int os::vm_page_size() { return os::win32::vm_page_size(); }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -115,8 +115,6 @@ class win32 {
|
||||
static address fast_jni_accessor_wrapper(BasicType);
|
||||
#endif
|
||||
|
||||
static void call_test_func_with_wrapper(void (*funcPtr)(void));
|
||||
|
||||
// filter function to ignore faults on serializations page
|
||||
static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -104,7 +104,4 @@ inline void os::exit(int num) {
|
||||
win32::exit_process_or_thread(win32::EPT_PROCESS, num);
|
||||
}
|
||||
|
||||
#define CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(f) \
|
||||
os::win32::call_test_func_with_wrapper(f)
|
||||
|
||||
#endif // OS_WINDOWS_VM_OS_WINDOWS_INLINE_HPP
|
||||
|
||||
@ -84,6 +84,9 @@
|
||||
|
||||
static jint CurrentVersion = JNI_VERSION_1_8;
|
||||
|
||||
#ifdef _WIN32
|
||||
extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
|
||||
#endif
|
||||
|
||||
// The DT_RETURN_MARK macros create a scoped object to fire the dtrace
|
||||
// '-return' probe regardless of the return path is taken out of the function.
|
||||
@ -3924,7 +3927,7 @@ void execute_internal_vm_tests() {
|
||||
DT_RETURN_MARK_DECL(CreateJavaVM, jint
|
||||
, HOTSPOT_JNI_CREATEJAVAVM_RETURN(_ret_ref));
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) {
|
||||
static jint JNI_CreateJavaVM_inner(JavaVM **vm, void **penv, void *args) {
|
||||
HOTSPOT_JNI_CREATEJAVAVM_ENTRY((void **) vm, penv, args);
|
||||
|
||||
jint result = JNI_ERR;
|
||||
@ -4001,18 +4004,14 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, v
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
#ifndef CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED
|
||||
#define CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(f) f()
|
||||
#endif
|
||||
|
||||
// Check if we should compile all classes on bootclasspath
|
||||
if (CompileTheWorld) ClassLoader::compile_the_world();
|
||||
if (ReplayCompiles) ciReplay::replay(thread);
|
||||
|
||||
// Some platforms (like Win*) need a wrapper around these test
|
||||
// functions in order to properly handle error conditions.
|
||||
CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(test_error_handler);
|
||||
CALL_TEST_FUNC_WITH_WRAPPER_IF_NEEDED(execute_internal_vm_tests);
|
||||
test_error_handler();
|
||||
execute_internal_vm_tests();
|
||||
#endif
|
||||
|
||||
// Since this is not a JVM_ENTRY we have to set the thread state manually before leaving.
|
||||
@ -4045,8 +4044,23 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, v
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) {
|
||||
jint result = 0;
|
||||
// On Windows, let CreateJavaVM run with SEH protection
|
||||
#ifdef _WIN32
|
||||
__try {
|
||||
#endif
|
||||
result = JNI_CreateJavaVM_inner(vm, penv, args);
|
||||
#ifdef _WIN32
|
||||
} __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
|
||||
// Nothing to do.
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
_JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) {
|
||||
// See bug 4367188, the wrapper can sometimes cause VM crashes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user