265 }
266
267 // Utility functions
268
269 // From IA32 System Programming Guide
270 enum {
271 trap_page_fault = 0xE
272 };
273
274 extern "C" JNIEXPORT int
275 JVM_handle_linux_signal(int sig,
276 siginfo_t* info,
277 void* ucVoid,
278 int abort_if_unrecognized) {
279 ucontext_t* uc = (ucontext_t*) ucVoid;
280
281 Thread* t = Thread::current_or_null_safe();
282
283 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
284 // (no destructors can be run)
285 os::WatcherThreadCrashProtection::check_crash_protection(sig, t);
286
287 SignalHandlerMark shm(t);
288
289 // Note: it's not uncommon that JNI code uses signal/sigset to install
290 // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
291 // or have a SIGILL handler when detecting CPU type). When that happens,
292 // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To
293 // avoid unnecessary crash when libjsig is not preloaded, try handle signals
294 // that do not require siginfo/ucontext first.
295
296 if (sig == SIGPIPE || sig == SIGXFSZ) {
297 // allow chained handler to go first
298 if (os::Linux::chained_handler(sig, info, ucVoid)) {
299 return true;
300 } else {
301 // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219
302 return true;
303 }
304 }
305
|
265 }
266
267 // Utility functions
268
269 // From IA32 System Programming Guide
270 enum {
271 trap_page_fault = 0xE
272 };
273
274 extern "C" JNIEXPORT int
275 JVM_handle_linux_signal(int sig,
276 siginfo_t* info,
277 void* ucVoid,
278 int abort_if_unrecognized) {
279 ucontext_t* uc = (ucontext_t*) ucVoid;
280
281 Thread* t = Thread::current_or_null_safe();
282
283 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
284 // (no destructors can be run)
285 os::ThreadCrashProtection::check_crash_protection(sig, t);
286
287 SignalHandlerMark shm(t);
288
289 // Note: it's not uncommon that JNI code uses signal/sigset to install
290 // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
291 // or have a SIGILL handler when detecting CPU type). When that happens,
292 // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To
293 // avoid unnecessary crash when libjsig is not preloaded, try handle signals
294 // that do not require siginfo/ucontext first.
295
296 if (sig == SIGPIPE || sig == SIGXFSZ) {
297 // allow chained handler to go first
298 if (os::Linux::chained_handler(sig, info, ucVoid)) {
299 return true;
300 } else {
301 // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219
302 return true;
303 }
304 }
305
|