static jboolean installSignals(Env* env) { #if defined(DARWIN) // On Darwin SIGBUS is generated when dereferencing NULL pointers if (installSignalHandlerIfNeeded(SIGBUS, create_sigaction(&signalHandler_npe_so_nochaining), NULL) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } #endif if (installSignalHandlerIfNeeded(SIGSEGV, create_sigaction(&signalHandler_npe_so_nochaining), NULL) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } if (installSignalHandlerIfNeeded(DUMP_THREAD_STACK_TRACE_SIGNAL, create_sigaction(&signalHandler_dump_thread), NULL) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } int err; if ((err = pthread_sigmask(0, NULL, &env->currentThread->signalMask)) != 0) { rvmThrowInternalErrorErrno(env, err); rvmTearDownSignals(env); return FALSE; } return TRUE; }
static jboolean reinstallSavedSignals(Env* env, SavedSignals* savedSignals) { if (installSignalHandlerIfNeeded(DUMP_THREAD_STACK_TRACE_SIGNAL, create_sigaction(&signalHandler_dump_thread), NULL) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } if (installSignalHandlerIfNeeded(BLOCKED_THREAD_SIGNAL, savedSignals->blockedThreadSignal, NULL) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } return TRUE; }
static jboolean installChainingSignals(Env* env) { #if defined(DARWIN) // On Darwin SIGBUS is generated when dereferencing NULL pointers if (installSignalHandlerIfNeeded(SIGBUS, create_sigaction(&signalHandler_npe_so_chaining), &sigbusFallback) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } #endif if (installSignalHandlerIfNeeded(SIGSEGV, create_sigaction(&signalHandler_npe_so_chaining), &sigsegvFallback) != 0) { rvmThrowInternalErrorErrno(env, errno); return FALSE; } return TRUE; }
static jboolean installNoChainingSignals(Env* env) { #if defined(DARWIN) // On Darwin SIGBUS is generated when dereferencing NULL pointers if (installSignalHandlerIfNeeded(SIGBUS, create_sigaction(&signalHandler_npe_so_nochaining), NULL) != 0) { bugvmThrowInternalErrorErrno(env, errno); return FALSE; } #endif if (installSignalHandlerIfNeeded(SIGSEGV, create_sigaction(&signalHandler_npe_so_nochaining), NULL) != 0) { bugvmThrowInternalErrorErrno(env, errno); return FALSE; } if (installSignalHandlerIfNeeded(DUMP_THREAD_STACK_TRACE_SIGNAL, create_sigaction(&signalHandler_dump_thread), NULL) != 0) { bugvmThrowInternalErrorErrno(env, errno); return FALSE; } return TRUE; }