445 }
446
447 // Utility functions
448
449 // From IA32 System Programming Guide
450 enum {
451 trap_page_fault = 0xE
452 };
453
454 extern "C" JNIEXPORT int
455 JVM_handle_bsd_signal(int sig,
456 siginfo_t* info,
457 void* ucVoid,
458 int abort_if_unrecognized) {
459 ucontext_t* uc = (ucontext_t*) ucVoid;
460
461 Thread* t = Thread::current_or_null_safe();
462
463 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
464 // (no destructors can be run)
465 os::WatcherThreadCrashProtection::check_crash_protection(sig, t);
466
467 SignalHandlerMark shm(t);
468
469 // Note: it's not uncommon that JNI code uses signal/sigset to install
470 // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
471 // or have a SIGILL handler when detecting CPU type). When that happens,
472 // JVM_handle_bsd_signal() might be invoked with junk info/ucVoid. To
473 // avoid unnecessary crash when libjsig is not preloaded, try handle signals
474 // that do not require siginfo/ucontext first.
475
476 if (sig == SIGPIPE || sig == SIGXFSZ) {
477 // allow chained handler to go first
478 if (os::Bsd::chained_handler(sig, info, ucVoid)) {
479 return true;
480 } else {
481 // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219
482 return true;
483 }
484 }
485
|
445 }
446
447 // Utility functions
448
449 // From IA32 System Programming Guide
450 enum {
451 trap_page_fault = 0xE
452 };
453
454 extern "C" JNIEXPORT int
455 JVM_handle_bsd_signal(int sig,
456 siginfo_t* info,
457 void* ucVoid,
458 int abort_if_unrecognized) {
459 ucontext_t* uc = (ucontext_t*) ucVoid;
460
461 Thread* t = Thread::current_or_null_safe();
462
463 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
464 // (no destructors can be run)
465 os::ThreadCrashProtection::check_crash_protection(sig, t);
466
467 SignalHandlerMark shm(t);
468
469 // Note: it's not uncommon that JNI code uses signal/sigset to install
470 // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
471 // or have a SIGILL handler when detecting CPU type). When that happens,
472 // JVM_handle_bsd_signal() might be invoked with junk info/ucVoid. To
473 // avoid unnecessary crash when libjsig is not preloaded, try handle signals
474 // that do not require siginfo/ucontext first.
475
476 if (sig == SIGPIPE || sig == SIGXFSZ) {
477 // allow chained handler to go first
478 if (os::Bsd::chained_handler(sig, info, ucVoid)) {
479 return true;
480 } else {
481 // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219
482 return true;
483 }
484 }
485
|