< prev index next >

src/os/linux/vm/vmError_linux.cpp

Print this page
rev 7905 : 8074552:  SafeFetch32 and SafeFetchN do not work in error handling
Summary: handle SafeFetch faults in secondary signal handlers
Contributed-by: Thomas Stuefe


  95 address VMError::get_resetted_sighandler(int sig) {
  96   for (int i = 0; i < NUM_SIGNALS; i++) {
  97     if (SIGNALS[i] == sig) {
  98       return resettedSighandler[i];
  99     }
 100   }
 101   return NULL;
 102 }
 103 
 104 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
 105   // unmask current signal
 106   sigset_t newset;
 107   sigemptyset(&newset);
 108   sigaddset(&newset, sig);
 109   // also unmask other synchronous signals
 110   for (int i = 0; i < NUM_SIGNALS; i++) {
 111     sigaddset(&newset, SIGNALS[i]);
 112   }
 113   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 114 
 115   VMError err(NULL, sig, NULL, info, ucVoid);









 116   err.report_and_die();
 117 }
 118 
 119 void VMError::reset_signal_handlers() {
 120   // install signal handlers for all synchronous program error signals
 121   sigset_t newset;
 122   sigemptyset(&newset);
 123 
 124   for (int i = 0; i < NUM_SIGNALS; i++) {
 125     save_signal(i, SIGNALS[i]);
 126     os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
 127     sigaddset(&newset, SIGNALS[i]);
 128   }
 129   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 130 
 131 }


  95 address VMError::get_resetted_sighandler(int sig) {
  96   for (int i = 0; i < NUM_SIGNALS; i++) {
  97     if (SIGNALS[i] == sig) {
  98       return resettedSighandler[i];
  99     }
 100   }
 101   return NULL;
 102 }
 103 
 104 static void crash_handler(int sig, siginfo_t* info, void* ucVoid) {
 105   // unmask current signal
 106   sigset_t newset;
 107   sigemptyset(&newset);
 108   sigaddset(&newset, sig);
 109   // also unmask other synchronous signals
 110   for (int i = 0; i < NUM_SIGNALS; i++) {
 111     sigaddset(&newset, SIGNALS[i]);
 112   }
 113   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 114 
 115   // support safefetch faults in error handling
 116   ucontext_t* const uc = (ucontext_t*) ucVoid;
 117   address const pc = uc ? os::Linux::ucontext_get_pc(uc) : NULL;
 118 
 119   if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
 120     os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
 121     return;
 122   }
 123 
 124   VMError err(NULL, sig, pc, info, ucVoid);
 125   err.report_and_die();
 126 }
 127 
 128 void VMError::reset_signal_handlers() {
 129   // install signal handlers for all synchronous program error signals
 130   sigset_t newset;
 131   sigemptyset(&newset);
 132 
 133   for (int i = 0; i < NUM_SIGNALS; i++) {
 134     save_signal(i, SIGNALS[i]);
 135     os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
 136     sigaddset(&newset, SIGNALS[i]);
 137   }
 138   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 139 
 140 }
< prev index next >