8253717: Relocate stack overflow code out of thread.hpp/cpp

Reviewed-by: rehn, dcubed, dholmes, stuefe
This commit is contained in:
Coleen Phillimore 2020-10-08 11:24:27 +00:00
parent 782d45bdec
commit 6bc493188b
50 changed files with 774 additions and 662 deletions

View file

@ -327,20 +327,21 @@ JVM_handle_linux_signal(int sig,
// Check if fault address is within thread stack.
if (thread->is_in_full_stack(addr)) {
// stack overflow
if (thread->in_stack_yellow_reserved_zone(addr)) {
StackOverflow* overflow_state = thread->stack_overflow_state();
if (overflow_state->in_stack_yellow_reserved_zone(addr)) {
if (thread->thread_state() == _thread_in_Java) {
if (thread->in_stack_reserved_zone(addr)) {
if (overflow_state->in_stack_reserved_zone(addr)) {
frame fr;
if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
assert(fr.is_java_frame(), "Must be a Javac frame");
frame activation =
SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
if (activation.sp() != NULL) {
thread->disable_stack_reserved_zone();
overflow_state->disable_stack_reserved_zone();
if (activation.is_interpreted_frame()) {
thread->set_reserved_stack_activation((address)activation.fp());
overflow_state->set_reserved_stack_activation((address)activation.fp());
} else {
thread->set_reserved_stack_activation((address)activation.unextended_sp());
overflow_state->set_reserved_stack_activation((address)activation.unextended_sp());
}
return 1;
}
@ -348,17 +349,17 @@ JVM_handle_linux_signal(int sig,
}
// Throw a stack overflow exception.
// Guard pages will be reenabled while unwinding the stack.
thread->disable_stack_yellow_reserved_zone();
overflow_state->disable_stack_yellow_reserved_zone();
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
} else {
// Thread was in the vm or native code. Return and try to finish.
thread->disable_stack_yellow_reserved_zone();
overflow_state->disable_stack_yellow_reserved_zone();
return 1;
}
} else if (thread->in_stack_red_zone(addr)) {
} else if (overflow_state->in_stack_red_zone(addr)) {
// Fatal red zone violation. Disable the guard pages and fall through
// to handle_unexpected_exception way down below.
thread->disable_stack_red_zone();
overflow_state->disable_stack_red_zone();
tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
// This is a likely cause, but hard to verify. Let's just print