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 *
342 if (StubRoutines::is_safefetch_fault(pc)) {
343 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
344 return 1;
345 }
346
347 #ifndef AMD64
348 // Halt if SI_KERNEL before more crashes get misdiagnosed as Java bugs
349 // This can happen in any running code (currently more frequently in
350 // interpreter code but has been seen in compiled code)
351 if (sig == SIGSEGV && info->si_addr == 0 && info->si_code == SI_KERNEL) {
352 fatal("An irrecoverable SI_KERNEL SIGSEGV has occurred due "
353 "to unstable signal handling in this distribution.");
354 }
355 #endif // AMD64
356
357 // Handle ALL stack overflow variations here
358 if (sig == SIGSEGV) {
359 address addr = (address) info->si_addr;
360
361 // check if fault address is within thread stack
362 if (thread->on_local_stack(addr)) {
363 // stack overflow
364 if (thread->in_stack_yellow_reserved_zone(addr)) {
365 if (thread->thread_state() == _thread_in_Java) {
366 if (thread->in_stack_reserved_zone(addr)) {
367 frame fr;
368 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
369 assert(fr.is_java_frame(), "Must be a Java frame");
370 frame activation =
371 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
372 if (activation.sp() != NULL) {
373 thread->disable_stack_reserved_zone();
374 if (activation.is_interpreted_frame()) {
375 thread->set_reserved_stack_activation((address)(
376 activation.fp() + frame::interpreter_frame_initial_sp_offset));
377 } else {
378 thread->set_reserved_stack_activation((address)activation.unextended_sp());
379 }
380 return 1;
381 }
382 }
|
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 *
342 if (StubRoutines::is_safefetch_fault(pc)) {
343 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
344 return 1;
345 }
346
347 #ifndef AMD64
348 // Halt if SI_KERNEL before more crashes get misdiagnosed as Java bugs
349 // This can happen in any running code (currently more frequently in
350 // interpreter code but has been seen in compiled code)
351 if (sig == SIGSEGV && info->si_addr == 0 && info->si_code == SI_KERNEL) {
352 fatal("An irrecoverable SI_KERNEL SIGSEGV has occurred due "
353 "to unstable signal handling in this distribution.");
354 }
355 #endif // AMD64
356
357 // Handle ALL stack overflow variations here
358 if (sig == SIGSEGV) {
359 address addr = (address) info->si_addr;
360
361 // check if fault address is within thread stack
362 if (thread->is_in_full_stack(addr)) {
363 // stack overflow
364 if (thread->in_stack_yellow_reserved_zone(addr)) {
365 if (thread->thread_state() == _thread_in_Java) {
366 if (thread->in_stack_reserved_zone(addr)) {
367 frame fr;
368 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
369 assert(fr.is_java_frame(), "Must be a Java frame");
370 frame activation =
371 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
372 if (activation.sp() != NULL) {
373 thread->disable_stack_reserved_zone();
374 if (activation.is_interpreted_frame()) {
375 thread->set_reserved_stack_activation((address)(
376 activation.fp() + frame::interpreter_frame_initial_sp_offset));
377 } else {
378 thread->set_reserved_stack_activation((address)activation.unextended_sp());
379 }
380 return 1;
381 }
382 }
|