1 /*
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
503 */
504 // decide if this trap can be handled by a stub
505 address stub = NULL;
506
507 address pc = NULL;
508
509 //%note os_trap_1
510 if (info != NULL && uc != NULL && thread != NULL) {
511 pc = (address) os::Bsd::ucontext_get_pc(uc);
512
513 if (StubRoutines::is_safefetch_fault(pc)) {
514 os::Bsd::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
515 return 1;
516 }
517
518 // Handle ALL stack overflow variations here
519 if (sig == SIGSEGV || sig == SIGBUS) {
520 address addr = (address) info->si_addr;
521
522 // check if fault address is within thread stack
523 if (thread->on_local_stack(addr)) {
524 // stack overflow
525 if (thread->in_stack_yellow_reserved_zone(addr)) {
526 if (thread->thread_state() == _thread_in_Java) {
527 if (thread->in_stack_reserved_zone(addr)) {
528 frame fr;
529 if (os::Bsd::get_frame_at_stack_banging_point(thread, uc, &fr)) {
530 assert(fr.is_java_frame(), "Must be a Java frame");
531 frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
532 if (activation.sp() != NULL) {
533 thread->disable_stack_reserved_zone();
534 if (activation.is_interpreted_frame()) {
535 thread->set_reserved_stack_activation((address)(
536 activation.fp() + frame::interpreter_frame_initial_sp_offset));
537 } else {
538 thread->set_reserved_stack_activation((address)activation.unextended_sp());
539 }
540 return 1;
541 }
542 }
543 }
|
1 /*
2 * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
503 */
504 // decide if this trap can be handled by a stub
505 address stub = NULL;
506
507 address pc = NULL;
508
509 //%note os_trap_1
510 if (info != NULL && uc != NULL && thread != NULL) {
511 pc = (address) os::Bsd::ucontext_get_pc(uc);
512
513 if (StubRoutines::is_safefetch_fault(pc)) {
514 os::Bsd::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
515 return 1;
516 }
517
518 // Handle ALL stack overflow variations here
519 if (sig == SIGSEGV || sig == SIGBUS) {
520 address addr = (address) info->si_addr;
521
522 // check if fault address is within thread stack
523 if (thread->is_in_full_stack(addr)) {
524 // stack overflow
525 if (thread->in_stack_yellow_reserved_zone(addr)) {
526 if (thread->thread_state() == _thread_in_Java) {
527 if (thread->in_stack_reserved_zone(addr)) {
528 frame fr;
529 if (os::Bsd::get_frame_at_stack_banging_point(thread, uc, &fr)) {
530 assert(fr.is_java_frame(), "Must be a Java frame");
531 frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
532 if (activation.sp() != NULL) {
533 thread->disable_stack_reserved_zone();
534 if (activation.is_interpreted_frame()) {
535 thread->set_reserved_stack_activation((address)(
536 activation.fp() + frame::interpreter_frame_initial_sp_offset));
537 } else {
538 thread->set_reserved_stack_activation((address)activation.unextended_sp());
539 }
540 return 1;
541 }
542 }
543 }
|