8176872: [s390] wrong pc shown in error logs
authorstuefe
Tue, 21 Mar 2017 14:14:06 +0100
changeset 46361 b4c026dd6128
parent 46360 c753322134b0
child 46363 b53de34a044c
8176872: [s390] wrong pc shown in error logs Reviewed-by: dholmes, dsamersoff
hotspot/src/os/posix/vm/vmError_posix.cpp
hotspot/src/os_cpu/linux_s390/vm/os_linux_s390.cpp
--- a/hotspot/src/os/posix/vm/vmError_posix.cpp	Fri Mar 17 19:05:45 2017 +0100
+++ b/hotspot/src/os/posix/vm/vmError_posix.cpp	Tue Mar 21 14:14:06 2017 +0100
@@ -115,7 +115,12 @@
 
   // support safefetch faults in error handling
   ucontext_t* const uc = (ucontext_t*) ucVoid;
-  address const pc = uc ? os::Posix::ucontext_get_pc(uc) : NULL;
+  address pc = (uc != NULL) ? os::Posix::ucontext_get_pc(uc) : NULL;
+
+  // Correct pc for SIGILL, SIGFPE (see JDK-8176872)
+  if (sig == SIGILL || sig == SIGFPE) {
+    pc = (address) info->si_addr;
+  }
 
   if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
     os::Posix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
--- a/hotspot/src/os_cpu/linux_s390/vm/os_linux_s390.cpp	Fri Mar 17 19:05:45 2017 +0100
+++ b/hotspot/src/os_cpu/linux_s390/vm/os_linux_s390.cpp	Tue Mar 21 14:14:06 2017 +0100
@@ -505,6 +505,14 @@
   sigaddset(&newset, sig);
   sigprocmask(SIG_UNBLOCK, &newset, NULL);
 
+  // Hand down correct pc for SIGILL, SIGFPE. pc from context
+  // usually points to the instruction after the failing instruction.
+  // Note: this should be combined with the trap_pc handling above,
+  // because it handles the same issue.
+  if (sig == SIGILL || sig == SIGFPE) {
+    pc = (address) info->si_addr;
+  }
+
   VMError::report_and_die(t, sig, pc, info, ucVoid);
 
   ShouldNotReachHere();