|
32 | 32 | #include "runtime/java.hpp" |
33 | 33 | #include "runtime/os.hpp" |
34 | 34 | #include "runtime/osThread.hpp" |
| 35 | +#include "runtime/stubRoutines.hpp" |
35 | 36 | #include "runtime/thread.hpp" |
36 | 37 | #include "signals_posix.hpp" |
37 | 38 | #include "utilities/events.hpp" |
38 | 39 | #include "utilities/ostream.hpp" |
39 | 40 | #include "utilities/vmError.hpp" |
40 | 41 |
|
| 42 | +#ifdef ZERO |
| 43 | +// See stubGenerator_zero.cpp |
| 44 | +#include <setjmp.h> |
| 45 | +extern sigjmp_buf* get_jmp_buf_for_continuation(); |
| 46 | +#endif |
| 47 | + |
41 | 48 | #include <signal.h> |
42 | 49 |
|
43 | 50 | // Various signal related mechanism are laid out in the following order: |
@@ -546,13 +553,36 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info, |
546 | 553 |
|
547 | 554 | // Handle assertion poison page accesses. |
548 | 555 | #ifdef CAN_SHOW_REGISTERS_ON_ASSERT |
549 | | - if ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison) { |
| 556 | + if (!signal_was_handled && |
| 557 | + ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison)) { |
550 | 558 | signal_was_handled = handle_assert_poison_fault(ucVoid, info->si_addr); |
551 | 559 | } |
552 | 560 | #endif |
553 | 561 |
|
| 562 | + if (!signal_was_handled) { |
| 563 | + // Handle SafeFetch access. |
| 564 | +#ifndef ZERO |
| 565 | + if (uc != NULL) { |
| 566 | + address pc = os::Posix::ucontext_get_pc(uc); |
| 567 | + if (StubRoutines::is_safefetch_fault(pc)) { |
| 568 | + os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); |
| 569 | + signal_was_handled = true; |
| 570 | + } |
| 571 | + } |
| 572 | +#else |
| 573 | + // See JDK-8076185 |
| 574 | + if (sig == SIGSEGV || sig == SIGBUS) { |
| 575 | + sigjmp_buf* const pjb = get_jmp_buf_for_continuation(); |
| 576 | + if (pjb) { |
| 577 | + siglongjmp(*pjb, 1); |
| 578 | + } |
| 579 | + } |
| 580 | +#endif // ZERO |
| 581 | + } |
| 582 | + |
554 | 583 | // Ignore SIGPIPE and SIGXFSZ (4229104, 6499219). |
555 | | - if (sig == SIGPIPE || sig == SIGXFSZ) { |
| 584 | + if (!signal_was_handled && |
| 585 | + (sig == SIGPIPE || sig == SIGXFSZ)) { |
556 | 586 | PosixSignals::chained_handler(sig, info, ucVoid); |
557 | 587 | signal_was_handled = true; // unconditionally. |
558 | 588 | } |
|
0 commit comments