< prev index next >

src/os/posix/vm/vmError_posix.cpp

Print this page
rev 12487 : 8166944: Hanging Error Reporting steps may lead to torn error logs.
Reviewed-by: cjplummer, dholmes
Summary: Interupt error reporting if reporting steps hang to enable subsequent reporting steps to run.


  42 #endif
  43 #ifdef AIX
  44 #include <unistd.h>
  45 #endif
  46 #ifdef BSD
  47 #include <sys/syscall.h>
  48 #include <unistd.h>
  49 #endif
  50 
  51 
  52 // handle all synchronous program error signals which may happen during error
  53 // reporting. They must be unblocked, caught, handled.
  54 
  55 static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
  56 static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
  57 
  58 // Space for our "saved" signal flags and handlers
  59 static int resettedSigflags[NUM_SIGNALS];
  60 static address resettedSighandler[NUM_SIGNALS];
  61 















  62 static void save_signal(int idx, int sig)
  63 {
  64   struct sigaction sa;
  65   sigaction(sig, NULL, &sa);
  66   resettedSigflags[idx]   = sa.sa_flags;
  67   resettedSighandler[idx] = (sa.sa_flags & SA_SIGINFO)
  68                               ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
  69                               : CAST_FROM_FN_PTR(address, sa.sa_handler);
  70 }
  71 
  72 int VMError::get_resetted_sigflags(int sig) {
  73   for (int i = 0; i < NUM_SIGNALS; i++) {
  74     if (SIGNALS[i] == sig) {
  75       return resettedSigflags[i];
  76     }
  77   }
  78   return -1;
  79 }
  80 
  81 address VMError::get_resetted_sighandler(int sig) {




  42 #endif
  43 #ifdef AIX
  44 #include <unistd.h>
  45 #endif
  46 #ifdef BSD
  47 #include <sys/syscall.h>
  48 #include <unistd.h>
  49 #endif
  50 
  51 
  52 // handle all synchronous program error signals which may happen during error
  53 // reporting. They must be unblocked, caught, handled.
  54 
  55 static const int SIGNALS[] = { SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP }; // add more if needed
  56 static const int NUM_SIGNALS = sizeof(SIGNALS) / sizeof(int);
  57 
  58 // Space for our "saved" signal flags and handlers
  59 static int resettedSigflags[NUM_SIGNALS];
  60 static address resettedSighandler[NUM_SIGNALS];
  61 
  62 // Needed for cancelable steps.
  63 static volatile pthread_t reporter_thread_id;
  64 
  65 void VMError::reporting_started() {
  66   // record pthread id of reporter thread.
  67   reporter_thread_id = ::pthread_self();
  68 }
  69 
  70 void VMError::interrupt_reporting_thread() {
  71   // We misuse SIGILL here, but it does not really matter. We need
  72   //  a signal which is handled by crash_handler and not likely to
  73   //  occurr during error reporting itself.
  74   ::pthread_kill(reporter_thread_id, SIGILL);
  75 }
  76 
  77 static void save_signal(int idx, int sig)
  78 {
  79   struct sigaction sa;
  80   sigaction(sig, NULL, &sa);
  81   resettedSigflags[idx]   = sa.sa_flags;
  82   resettedSighandler[idx] = (sa.sa_flags & SA_SIGINFO)
  83                               ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
  84                               : CAST_FROM_FN_PTR(address, sa.sa_handler);
  85 }
  86 
  87 int VMError::get_resetted_sigflags(int sig) {
  88   for (int i = 0; i < NUM_SIGNALS; i++) {
  89     if (SIGNALS[i] == sig) {
  90       return resettedSigflags[i];
  91     }
  92   }
  93   return -1;
  94 }
  95 
  96 address VMError::get_resetted_sighandler(int sig) {


< prev index next >