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 }
|
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::report_and_die(NULL, sig, pc, info, ucVoid);
125 }
126
127 void VMError::reset_signal_handlers() {
128 // install signal handlers for all synchronous program error signals
129 sigset_t newset;
130 sigemptyset(&newset);
131
132 for (int i = 0; i < NUM_SIGNALS; i++) {
133 save_signal(i, SIGNALS[i]);
134 os::signal(SIGNALS[i], CAST_FROM_FN_PTR(void *, crash_handler));
135 sigaddset(&newset, SIGNALS[i]);
136 }
137 pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
138
139 }
|