8144219: [posix] Remove redundant code around os::print_siginfo()
Summary: for posix platforms, consolidate os::print_siginfo() in os_posix.cpp and remove cds fault special handling
Reviewed-by: dholmes, simonis
--- a/hotspot/src/os/aix/vm/os_aix.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/aix/vm/os_aix.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -1647,11 +1647,6 @@
st->cr();
}
-void os::print_siginfo(outputStream* st, void* siginfo) {
- os::Posix::print_siginfo_brief(st, (const siginfo_t*) siginfo);
- st->cr();
-}
-
static void print_signal_handler(outputStream* st, int sig,
char* buf, size_t buflen);
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -1710,24 +1710,6 @@
st->cr();
}
-void os::print_siginfo(outputStream* st, void* siginfo) {
- const siginfo_t* si = (const siginfo_t*)siginfo;
-
- os::Posix::print_siginfo_brief(st, si);
-
- if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
- UseSharedSpaces) {
- FileMapInfo* mapinfo = FileMapInfo::current_info();
- if (mapinfo->is_in_shared_space(si->si_addr)) {
- st->print("\n\nError accessing class data sharing archive." \
- " Mapped file inaccessible during execution, " \
- " possible disk/network problem.");
- }
- }
- st->cr();
-}
-
-
static void print_signal_handler(outputStream* st, int sig,
char* buf, size_t buflen);
--- a/hotspot/src/os/linux/vm/os_linux.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -2237,25 +2237,6 @@
#endif
}
-void os::print_siginfo(outputStream* st, void* siginfo) {
- const siginfo_t* si = (const siginfo_t*)siginfo;
-
- os::Posix::print_siginfo_brief(st, si);
-#if INCLUDE_CDS
- if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
- UseSharedSpaces) {
- FileMapInfo* mapinfo = FileMapInfo::current_info();
- if (mapinfo->is_in_shared_space(si->si_addr)) {
- st->print("\n\nError accessing class data sharing archive." \
- " Mapped file inaccessible during execution, " \
- " possible disk/network problem.");
- }
- }
-#endif
- st->cr();
-}
-
-
static void print_signal_handler(outputStream* st, int sig,
char* buf, size_t buflen);
--- a/hotspot/src/os/posix/vm/os_posix.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/posix/vm/os_posix.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -981,50 +981,60 @@
return true;
}
-// A POSIX conform, platform-independend siginfo print routine.
-// Short print out on one line.
-void os::Posix::print_siginfo_brief(outputStream* os, const siginfo_t* si) {
+void os::print_siginfo(outputStream* os, const void* si0) {
+
+ const siginfo_t* const si = (const siginfo_t*) si0;
+
char buf[20];
- os->print("siginfo: ");
+ os->print("siginfo:");
if (!si) {
- os->print("<null>");
+ os->print(" <null>");
return;
}
- // See print_siginfo_full() for details.
const int sig = si->si_signo;
- os->print("si_signo: %d (%s)", sig, os::Posix::get_signal_name(sig, buf, sizeof(buf)));
+ os->print(" si_signo: %d (%s)", sig, os::Posix::get_signal_name(sig, buf, sizeof(buf)));
enum_sigcode_desc_t ed;
- if (get_signal_code_description(si, &ed)) {
- os->print(", si_code: %d (%s)", si->si_code, ed.s_name);
- } else {
- os->print(", si_code: %d (unknown)", si->si_code);
- }
+ get_signal_code_description(si, &ed);
+ os->print(", si_code: %d (%s)", si->si_code, ed.s_name);
if (si->si_errno) {
os->print(", si_errno: %d", si->si_errno);
}
- const int me = (int) ::getpid();
- const int pid = (int) si->si_pid;
+ // Output additional information depending on the signal code.
+ // Note: Many implementations lump si_addr, si_pid, si_uid etc. together as unions,
+ // so it depends on the context which member to use. For synchronous error signals,
+ // we print si_addr, unless the signal was sent by another process or thread, in
+ // which case we print out pid or tid of the sender.
if (si->si_code == SI_USER || si->si_code == SI_QUEUE) {
- if (IS_VALID_PID(pid) && pid != me) {
- os->print(", sent from pid: %d (uid: %d)", pid, (int) si->si_uid);
+ const pid_t pid = si->si_pid;
+ os->print(", si_pid: %ld", (long) pid);
+ if (IS_VALID_PID(pid)) {
+ const pid_t me = getpid();
+ if (me == pid) {
+ os->print(" (current process)");
+ }
+ } else {
+ os->print(" (invalid)");
+ }
+ os->print(", si_uid: %ld", (long) si->si_uid);
+ if (sig == SIGCHLD) {
+ os->print(", si_status: %d", si->si_status);
}
} else if (sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
sig == SIGTRAP || sig == SIGFPE) {
os->print(", si_addr: " PTR_FORMAT, p2i(si->si_addr));
#ifdef SIGPOLL
} else if (sig == SIGPOLL) {
- os->print(", si_band: " PTR64_FORMAT, (uint64_t)si->si_band);
+ os->print(", si_band: %ld", si->si_band);
#endif
- } else if (sig == SIGCHLD) {
- os->print_cr(", si_pid: %d, si_uid: %d, si_status: %d", (int) si->si_pid, si->si_uid, si->si_status);
}
+
}
int os::Posix::unblock_thread_signal_mask(const sigset_t *set) {
--- a/hotspot/src/os/posix/vm/os_posix.hpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/posix/vm/os_posix.hpp Wed Dec 09 14:56:02 2015 +0100
@@ -73,9 +73,6 @@
// Prints a one-line description of a combination of sigaction.sa_flags.
static void print_sa_flags(outputStream* st, int flags);
- // A POSIX conform, platform-independend siginfo print routine.
- static void print_siginfo_brief(outputStream* os, const siginfo_t* si);
-
static address ucontext_get_pc(const ucontext_t* ctx);
// Set PC into context. Needed for continuation after signal.
static void ucontext_set_pc(ucontext_t* ctx, address pc);
--- a/hotspot/src/os/posix/vm/vmError_posix.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/posix/vm/vmError_posix.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
+#include "memory/filemap.hpp"
#include "runtime/arguments.hpp"
#include "runtime/os.hpp"
#include "runtime/thread.hpp"
@@ -122,3 +123,22 @@
os::Posix::unblock_thread_signal_mask(&newset);
}
+
+// Write a hint to the stream in case siginfo relates to a segv/bus error
+// and the offending address points into CDS archive.
+void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
+ if (siginfo && UseSharedSpaces) {
+ const siginfo_t* const si = (siginfo_t*)siginfo;
+ if (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) {
+ const void* const fault_addr = si->si_addr;
+ if (fault_addr != NULL) {
+ FileMapInfo* const mapinfo = FileMapInfo::current_info();
+ if (mapinfo->is_in_shared_space(fault_addr)) {
+ st->print("Error accessing class data sharing archive. "
+ "Mapped file inaccessible during execution, possible disk/network problem.");
+ }
+ }
+ }
+ }
+}
+
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -1906,23 +1906,6 @@
(void) check_addr0(st);
}
-void os::print_siginfo(outputStream* st, void* siginfo) {
- const siginfo_t* si = (const siginfo_t*)siginfo;
-
- os::Posix::print_siginfo_brief(st, si);
-
- if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) &&
- UseSharedSpaces) {
- FileMapInfo* mapinfo = FileMapInfo::current_info();
- if (mapinfo->is_in_shared_space(si->si_addr)) {
- st->print("\n\nError accessing class data sharing archive." \
- " Mapped file inaccessible during execution, " \
- " possible disk/network problem.");
- }
- }
- st->cr();
-}
-
// Moved from whole group, because we need them here for diagnostic
// prints.
#define OLDMAXSIGNUM 32
--- a/hotspot/src/os/windows/vm/os_windows.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -1798,8 +1798,8 @@
st->cr();
}
-void os::print_siginfo(outputStream *st, void *siginfo) {
- EXCEPTION_RECORD* er = (EXCEPTION_RECORD*)siginfo;
+void os::print_siginfo(outputStream *st, const void* siginfo) {
+ const EXCEPTION_RECORD* const er = (EXCEPTION_RECORD*)siginfo;
st->print("siginfo:");
char tmp[64];
@@ -1819,15 +1819,6 @@
er->ExceptionInformation[0]);
}
st->print(" " INTPTR_FORMAT, er->ExceptionInformation[1]);
-
- if (er->ExceptionCode == EXCEPTION_IN_PAGE_ERROR && UseSharedSpaces) {
- FileMapInfo* mapinfo = FileMapInfo::current_info();
- if (mapinfo->is_in_shared_space((void*)er->ExceptionInformation[1])) {
- st->print("\n\nError accessing class data sharing archive." \
- " Mapped file inaccessible during execution, " \
- " possible disk/network problem.");
- }
- }
} else {
int num = er->NumberParameters;
if (num > 0) {
--- a/hotspot/src/os/windows/vm/vmError_windows.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/os/windows/vm/vmError_windows.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
+#include "memory/filemap.hpp"
#include "runtime/arguments.hpp"
#include "runtime/os.hpp"
#include "runtime/thread.hpp"
@@ -46,3 +47,22 @@
void VMError::reset_signal_handlers() {
SetUnhandledExceptionFilter(crash_handler);
}
+
+// Write a hint to the stream in case siginfo relates to a segv/bus error
+// and the offending address points into CDS archive.
+void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
+ if (siginfo && UseSharedSpaces) {
+ const EXCEPTION_RECORD* const er = (const EXCEPTION_RECORD*)siginfo;
+ if (er->ExceptionCode == EXCEPTION_IN_PAGE_ERROR &&
+ er->NumberParameters >= 2) {
+ const void* const fault_addr = (const void*) er->ExceptionInformation[1];
+ if (fault_addr != NULL) {
+ FileMapInfo* const mapinfo = FileMapInfo::current_info();
+ if (mapinfo->is_in_shared_space(fault_addr)) {
+ st->print("Error accessing class data sharing archive. "
+ "Mapped file inaccessible during execution, possible disk/network problem.");
+ }
+ }
+ }
+ }
+}
--- a/hotspot/src/share/vm/runtime/os.hpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/share/vm/runtime/os.hpp Wed Dec 09 14:56:02 2015 +0100
@@ -606,7 +606,7 @@
static void print_environment_variables(outputStream* st, const char** env_list);
static void print_context(outputStream* st, const void* context);
static void print_register_info(outputStream* st, const void* context);
- static void print_siginfo(outputStream* st, void* siginfo);
+ static void print_siginfo(outputStream* st, const void* siginfo);
static void print_signal_handlers(outputStream* st, char* buf, size_t buflen);
static void print_date_and_time(outputStream* st, char* buf, size_t buflen);
--- a/hotspot/src/share/vm/utilities/vmError.cpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/share/vm/utilities/vmError.cpp Wed Dec 09 14:56:02 2015 +0100
@@ -597,6 +597,14 @@
st->cr();
}
+ STEP(245, "(CDS archive access warning)" )
+
+ // Print an explicit hint if we crashed on access to the CDS archive.
+ if (_verbose && _siginfo) {
+ check_failing_cds_access(st, _siginfo);
+ st->cr();
+ }
+
STEP(250, "(printing register info)")
// decode register contents if possible
--- a/hotspot/src/share/vm/utilities/vmError.hpp Mon Dec 07 09:19:26 2015 -0800
+++ b/hotspot/src/share/vm/utilities/vmError.hpp Wed Dec 09 14:56:02 2015 +0100
@@ -92,6 +92,10 @@
return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
}
+ // Write a hint to the stream in case siginfo relates to a segv/bus error
+ // and the offending address points into CDS store.
+ static void check_failing_cds_access(outputStream* st, const void* siginfo);
+
static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo,
void* context, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(6, 7);
static void report_and_die(const char* message, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(2, 3);