forked from OSchip/llvm-project
[tsan] Fix signals and setjmp/longjmp on OS X
1) There's a few wrongly defined things in tsan_interceptors.cc, 2) a typo in tsan_rtl_amd64.S which calls setjmp instead of sigsetjmp in the interceptor, and 3) on OS X, accessing an mprotected page results in a SIGBUS (and not SIGSEGV). Differential Revision: http://reviews.llvm.org/D15052 llvm-svn: 254299
This commit is contained in:
parent
6fd0675925
commit
77ff411247
|
@ -160,6 +160,9 @@ struct sigaction_t {
|
|||
#if SANITIZER_FREEBSD
|
||||
int sa_flags;
|
||||
__sanitizer_sigset_t sa_mask;
|
||||
#elif SANITIZER_MAC
|
||||
__sanitizer_sigset_t sa_mask;
|
||||
int sa_flags;
|
||||
#else
|
||||
__sanitizer_sigset_t sa_mask;
|
||||
#ifndef __mips__
|
||||
|
@ -172,7 +175,7 @@ struct sigaction_t {
|
|||
const sighandler_t SIG_DFL = (sighandler_t)0;
|
||||
const sighandler_t SIG_IGN = (sighandler_t)1;
|
||||
const sighandler_t SIG_ERR = (sighandler_t)-1;
|
||||
#if SANITIZER_FREEBSD
|
||||
#if SANITIZER_FREEBSD || SANITIZER_MAC
|
||||
const int SA_SIGINFO = 0x40;
|
||||
const int SIG_SETMASK = 3;
|
||||
#elif defined(__mips__)
|
||||
|
@ -2033,7 +2036,7 @@ TSAN_INTERCEPTOR(int, sigaction, int sig, sigaction_t *act, sigaction_t *old) {
|
|||
sigactions[sig].sa_flags = *(volatile int*)&act->sa_flags;
|
||||
internal_memcpy(&sigactions[sig].sa_mask, &act->sa_mask,
|
||||
sizeof(sigactions[sig].sa_mask));
|
||||
#if !SANITIZER_FREEBSD
|
||||
#if !SANITIZER_FREEBSD && !SANITIZER_MAC
|
||||
sigactions[sig].sa_restorer = act->sa_restorer;
|
||||
#endif
|
||||
sigaction_t newact;
|
||||
|
|
|
@ -300,7 +300,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
|
|||
movq _ZN14__interception14real_sigsetjmpE@GOTPCREL(%rip), %rdx
|
||||
jmp *(%rdx)
|
||||
#else
|
||||
jmp ASM_TSAN_SYMBOL(setjmp)
|
||||
jmp ASM_TSAN_SYMBOL(sigsetjmp)
|
||||
#endif
|
||||
CFI_ENDPROC
|
||||
ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp))
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define SIGNAL_TO_HANDLE SIGBUS
|
||||
#else
|
||||
#define SIGNAL_TO_HANDLE SIGSEGV
|
||||
#endif
|
||||
|
||||
sigjmp_buf fault_jmp;
|
||||
volatile int fault_expected;
|
||||
|
||||
|
@ -44,7 +50,7 @@ int main() {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (sigaction(SIGSEGV, &act, NULL)) {
|
||||
if (sigaction(SIGNAL_TO_HANDLE, &act, NULL)) {
|
||||
perror("sigaction");
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue