From 01a7e4ca6b654946fba54dcf11fb04da3731138b Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 10 Nov 2017 19:22:51 +0000 Subject: [PATCH] [tsan] Extract sigaction_impl and signal_impl Preparation for switching to sanitizer_signal_interceptors.inc Part of https://github.com/google/sanitizers/issues/637 llvm-svn: 317913 --- compiler-rt/lib/tsan/rtl/tsan_interceptors.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc index 87051e9ce38f..5ecbeb0e8a60 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc @@ -1950,8 +1950,17 @@ static void rtl_sigaction(int sig, __sanitizer_siginfo *info, void *ctx) { rtl_generic_sighandler(true, sig, info, ctx); } +static int sigaction_impl(int sig, __sanitizer_sigaction *act, + __sanitizer_sigaction *old); +static sighandler_t signal_impl(int sig, sighandler_t h); + TSAN_INTERCEPTOR(int, sigaction, int sig, __sanitizer_sigaction *act, __sanitizer_sigaction *old) { + return sigaction_impl(sig, act, old); +} + +int sigaction_impl(int sig, __sanitizer_sigaction *act, + __sanitizer_sigaction *old) { // Note: if we call REAL(sigaction) directly for any reason without proxying // the signal handler through rtl_sigaction, very bad things will happen. // The handler will run synchronously and corrupt tsan per-thread state. @@ -1989,6 +1998,10 @@ TSAN_INTERCEPTOR(int, sigaction, int sig, __sanitizer_sigaction *act, } TSAN_INTERCEPTOR(sighandler_t, signal, int sig, sighandler_t h) { + return signal_impl(sig, h); +} + +static sighandler_t signal_impl(int sig, sighandler_t h) { __sanitizer_sigaction act; act.handler = h; internal_memset(&act.sa_mask, -1, sizeof(act.sa_mask));