mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-15 10:23:28 +00:00
8250810: Push missing parts of JDK-8248817
Push changes from JDK-8248817 that were accidentally excluded from the commit. Reviewed-by: kbarrett, dholmes
This commit is contained in:
parent
cf345fd768
commit
a4eaf9536c
@ -2380,7 +2380,8 @@ LONG WINAPI topLevelVectoredExceptionFilter(struct _EXCEPTION_POINTERS* exceptio
|
||||
//-----------------------------------------------------------------------------
|
||||
LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
|
||||
DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
|
||||
PEXCEPTION_RECORD exception_record = exceptionInfo->ExceptionRecord;
|
||||
DWORD exception_code = exception_record->ExceptionCode;
|
||||
#ifdef _M_AMD64
|
||||
address pc = (address) exceptionInfo->ContextRecord->Rip;
|
||||
#else
|
||||
@ -2399,9 +2400,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
// This is safe to do because we have a new/unique ExceptionInformation
|
||||
// code for this condition.
|
||||
if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
|
||||
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
|
||||
int exception_subcode = (int) exceptionRecord->ExceptionInformation[0];
|
||||
address addr = (address) exceptionRecord->ExceptionInformation[1];
|
||||
int exception_subcode = (int) exception_record->ExceptionInformation[0];
|
||||
address addr = (address) exception_record->ExceptionInformation[1];
|
||||
|
||||
if (exception_subcode == EXCEPTION_INFO_EXEC_VIOLATION) {
|
||||
int page_size = os::vm_page_size();
|
||||
@ -2465,7 +2465,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
|
||||
// Last unguard failed or not unguarding
|
||||
tty->print_raw_cr("Execution protection violation");
|
||||
report_error(t, exception_code, addr, exceptionInfo->ExceptionRecord,
|
||||
report_error(t, exception_code, addr, exception_record,
|
||||
exceptionInfo->ContextRecord);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
@ -2481,14 +2481,14 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
if (t != NULL && t->is_Java_thread()) {
|
||||
JavaThread* thread = (JavaThread*) t;
|
||||
bool in_java = thread->thread_state() == _thread_in_Java;
|
||||
bool in_native = thread->thread_state() == _thread_in_native;
|
||||
bool in_vm = thread->thread_state() == _thread_in_vm;
|
||||
|
||||
// Handle potential stack overflows up front.
|
||||
if (exception_code == EXCEPTION_STACK_OVERFLOW) {
|
||||
if (thread->stack_guards_enabled()) {
|
||||
if (in_java) {
|
||||
frame fr;
|
||||
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
|
||||
address addr = (address) exceptionRecord->ExceptionInformation[1];
|
||||
if (os::win32::get_frame_at_stack_banging_point(thread, exceptionInfo, pc, &fr)) {
|
||||
assert(fr.is_java_frame(), "Must be a Java frame");
|
||||
SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
|
||||
@ -2497,7 +2497,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
// Yellow zone violation. The o/s has unprotected the first yellow
|
||||
// zone page for us. Note: must call disable_stack_yellow_zone to
|
||||
// update the enabled status, even if the zone contains only one page.
|
||||
assert(thread->thread_state() != _thread_in_vm, "Undersized StackShadowPages");
|
||||
assert(!in_vm, "Undersized StackShadowPages");
|
||||
thread->disable_stack_yellow_reserved_zone();
|
||||
// If not in java code, return and hope for the best.
|
||||
return in_java
|
||||
@ -2507,15 +2507,14 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
// Fatal red zone violation.
|
||||
thread->disable_stack_red_zone();
|
||||
tty->print_raw_cr("An unrecoverable stack overflow has occurred.");
|
||||
report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
|
||||
report_error(t, exception_code, pc, exception_record,
|
||||
exceptionInfo->ContextRecord);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
} else if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
|
||||
// Either stack overflow or null pointer exception.
|
||||
if (in_java) {
|
||||
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
|
||||
address addr = (address) exceptionRecord->ExceptionInformation[1];
|
||||
// Either stack overflow or null pointer exception.
|
||||
address addr = (address) exception_record->ExceptionInformation[1];
|
||||
address stack_end = thread->stack_end();
|
||||
if (addr < stack_end && addr >= stack_end - os::vm_page_size()) {
|
||||
// Stack overflow.
|
||||
@ -2534,47 +2533,38 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
return Handle_Exception(exceptionInfo, stub);
|
||||
}
|
||||
}
|
||||
{
|
||||
#ifdef _WIN64
|
||||
// If it's a legal stack address map the entire region in
|
||||
//
|
||||
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
|
||||
address addr = (address) exceptionRecord->ExceptionInformation[1];
|
||||
if (thread->is_in_usable_stack(addr)) {
|
||||
addr = (address)((uintptr_t)addr &
|
||||
(~((uintptr_t)os::vm_page_size() - (uintptr_t)1)));
|
||||
os::commit_memory((char *)addr, thread->stack_base() - addr,
|
||||
!ExecMem);
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// Null pointer exception.
|
||||
if (MacroAssembler::uses_implicit_null_check((void*)addr)) {
|
||||
address stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
|
||||
if (stub != NULL) return Handle_Exception(exceptionInfo, stub);
|
||||
}
|
||||
report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
|
||||
exceptionInfo->ContextRecord);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
// If it's a legal stack address map the entire region in
|
||||
if (thread->is_in_usable_stack(addr)) {
|
||||
addr = (address)((uintptr_t)addr &
|
||||
(~((uintptr_t)os::vm_page_size() - (uintptr_t)1)));
|
||||
os::commit_memory((char *)addr, thread->stack_base() - addr,
|
||||
!ExecMem);
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
#endif
|
||||
// Null pointer exception.
|
||||
if (MacroAssembler::uses_implicit_null_check((void*)addr)) {
|
||||
address stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
|
||||
if (stub != NULL) return Handle_Exception(exceptionInfo, stub);
|
||||
}
|
||||
report_error(t, exception_code, pc, exception_record,
|
||||
exceptionInfo->ContextRecord);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
#ifdef _WIN64
|
||||
// Special care for fast JNI field accessors.
|
||||
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks
|
||||
// in and the heap gets shrunk before the field access.
|
||||
if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
|
||||
address addr = JNI_FastGetField::find_slowcase_pc(pc);
|
||||
if (addr != (address)-1) {
|
||||
return Handle_Exception(exceptionInfo, addr);
|
||||
}
|
||||
address slowcase_pc = JNI_FastGetField::find_slowcase_pc(pc);
|
||||
if (slowcase_pc != (address)-1) {
|
||||
return Handle_Exception(exceptionInfo, slowcase_pc);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Stack overflow or null pointer exception in native code.
|
||||
report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
|
||||
report_error(t, exception_code, pc, exception_record,
|
||||
exceptionInfo->ContextRecord);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
} // /EXCEPTION_ACCESS_VIOLATION
|
||||
@ -2588,11 +2578,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
|
||||
}
|
||||
|
||||
bool is_unsafe_arraycopy = (thread->thread_state() == _thread_in_native || in_java) && UnsafeCopyMemory::contains_pc(pc);
|
||||
if (((thread->thread_state() == _thread_in_vm ||
|
||||
thread->thread_state() == _thread_in_native ||
|
||||
is_unsafe_arraycopy) &&
|
||||
thread->doing_unsafe_access()) ||
|
||||
bool is_unsafe_arraycopy = (in_native || in_java) && UnsafeCopyMemory::contains_pc(pc);
|
||||
if (((in_vm || in_native || is_unsafe_arraycopy) && thread->doing_unsafe_access()) ||
|
||||
(nm != NULL && nm->has_unsafe_access())) {
|
||||
address next_pc = Assembler::locate_next_instruction(pc);
|
||||
if (is_unsafe_arraycopy) {
|
||||
@ -2612,16 +2599,14 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
|
||||
|
||||
} // switch
|
||||
}
|
||||
if (((thread->thread_state() == _thread_in_Java) ||
|
||||
(thread->thread_state() == _thread_in_native)) &&
|
||||
exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
|
||||
if ((in_java || in_native) && exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
|
||||
LONG result=Handle_FLT_Exception(exceptionInfo);
|
||||
if (result==EXCEPTION_CONTINUE_EXECUTION) return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (exception_code != EXCEPTION_BREAKPOINT) {
|
||||
report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
|
||||
report_error(t, exception_code, pc, exception_record,
|
||||
exceptionInfo->ContextRecord);
|
||||
}
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
@ -63,33 +63,22 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava)
|
||||
// we try to glean some information out of the CONTEXT
|
||||
// if we were running Java code when SIGPROF came in.
|
||||
if (isInJava) {
|
||||
CONTEXT* uc = (CONTEXT*)ucontext;
|
||||
|
||||
#ifdef AMD64
|
||||
intptr_t* ret_fp = (intptr_t*) uc->Rbp;
|
||||
intptr_t* ret_sp = (intptr_t*) uc->Rsp;
|
||||
address addr = (address)uc->Rip;
|
||||
#else
|
||||
intptr_t* ret_fp = (intptr_t*) uc->Ebp;
|
||||
intptr_t* ret_sp = (intptr_t*) uc->Esp;
|
||||
address addr = (address)uc->Eip;
|
||||
#endif // AMD64
|
||||
if (addr == NULL || ret_sp == NULL ) {
|
||||
frame ret_frame = os::fetch_frame_from_context(ucontext);
|
||||
if (ret_frame.pc() == NULL || ret_frame.sp() == NULL ) {
|
||||
// CONTEXT wasn't useful
|
||||
return false;
|
||||
}
|
||||
|
||||
if (MetaspaceShared::is_in_trampoline_frame(addr)) {
|
||||
if (MetaspaceShared::is_in_trampoline_frame(ret_frame.pc())) {
|
||||
// In the middle of a trampoline call. Bail out for safety.
|
||||
// This happens rarely so shouldn't affect profiling.
|
||||
return false;
|
||||
}
|
||||
|
||||
frame ret_frame(ret_sp, ret_fp, addr);
|
||||
if (!ret_frame.safe_for_sender(jt)) {
|
||||
#if COMPILER2_OR_JVMCI
|
||||
// C2 and JVMCI use ebp as a general register see if NULL fp helps
|
||||
frame ret_frame2(ret_sp, NULL, addr);
|
||||
frame ret_frame2(ret_frame.sp(), NULL, ret_frame.pc());
|
||||
if (!ret_frame2.safe_for_sender(jt)) {
|
||||
// nothing else to try if the frame isn't good
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user