JDK-8257828: SafeFetch may crash if invoked in non-JavaThreads diff --git a/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp b/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp index 3986d57e818..befe4df4755 100644 --- a/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp +++ b/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp @@ -356,6 +356,15 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, assert(sig == info->si_signo, "bad siginfo"); } + // Handle SafeFetch faults: + if (uc != NULL) { + address const pc = (address) uc->uc_mcontext.gregs[REG_PC]; + if (pc && StubRoutines::is_safefetch_fault(pc)) { + os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); + return 1; + } + } + // decide if this trap can be handled by a stub address stub = NULL; @@ -366,11 +375,6 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, // factor me: getPCfromContext pc = (address) uc->uc_mcontext.gregs[REG_PC]; - if (StubRoutines::is_safefetch_fault(pc)) { - os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); - return true; - } - // Handle ALL stack overflow variations here if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) { address addr = (address) info->si_addr;