[compiler-rt] r178865 - [msan] A runtime option to disable wrapping of signal handlers.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Apr 5 04:59:16 PDT 2013
Author: eugenis
Date: Fri Apr 5 06:59:16 2013
New Revision: 178865
URL: http://llvm.org/viewvc/llvm-project?rev=178865&view=rev
Log:
[msan] A runtime option to disable wrapping of signal handlers.
Modified:
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/msan/msan_flags.h
compiler-rt/trunk/lib/msan/msan_interceptors.cc
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=178865&r1=178864&r2=178865&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Fri Apr 5 06:59:16 2013
@@ -129,6 +129,7 @@ static void ParseFlagsFromString(Flags *
ParseFlag(str, &f->strip_path_prefix, "strip_path_prefix");
ParseFlag(str, &f->fast_unwind_on_fatal, "fast_unwind_on_fatal");
ParseFlag(str, &f->fast_unwind_on_malloc, "fast_unwind_on_malloc");
+ ParseFlag(str, &f->wrap_signals, "wrap_signals");
}
static void InitializeFlags(Flags *f, const char *options) {
@@ -144,6 +145,7 @@ static void InitializeFlags(Flags *f, co
f->strip_path_prefix = "";
f->fast_unwind_on_fatal = false;
f->fast_unwind_on_malloc = true;
+ f->wrap_signals = true;
// Override from user-specified string.
if (__msan_default_options)
Modified: compiler-rt/trunk/lib/msan/msan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_flags.h?rev=178865&r1=178864&r2=178865&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_flags.h (original)
+++ compiler-rt/trunk/lib/msan/msan_flags.h Fri Apr 5 06:59:16 2013
@@ -30,6 +30,7 @@ struct Flags {
bool fast_unwind_on_fatal;
// Use fast (frame-pointer-based) unwinder on malloc/free (if available).
bool fast_unwind_on_malloc;
+ bool wrap_signals;
};
Flags *flags();
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=178865&r1=178864&r2=178865&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Apr 5 06:59:16 2013
@@ -848,38 +848,51 @@ INTERCEPTOR(int, sigaction, int signo, c
ENSURE_MSAN_INITED();
// FIXME: check that *act is unpoisoned.
// That requires intercepting all of sigemptyset, sigfillset, etc.
- SpinMutexLock lock(&sigactions_mu);
- CHECK_LT(signo, kMaxSignals);
- uptr old_cb = sigactions[signo];
- __sanitizer_sigaction new_act;
- __sanitizer_sigaction *pnew_act = act ? &new_act : 0;
- if (act) {
- internal_memcpy(pnew_act, act, __sanitizer::struct_sigaction_sz);
- uptr cb = __sanitizer::__sanitizer_get_sigaction_sa_sigaction(pnew_act);
- uptr new_cb = __sanitizer::__sanitizer_get_sigaction_sa_siginfo(pnew_act) ?
- (uptr)SignalAction : (uptr)SignalHandler;
- if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
- sigactions[signo] = cb;
- __sanitizer::__sanitizer_set_sigaction_sa_sigaction(pnew_act, new_cb);
+ int res;
+ if (flags()->wrap_signals) {
+ SpinMutexLock lock(&sigactions_mu);
+ CHECK_LT(signo, kMaxSignals);
+ uptr old_cb = sigactions[signo];
+ __sanitizer_sigaction new_act;
+ __sanitizer_sigaction *pnew_act = act ? &new_act : 0;
+ if (act) {
+ internal_memcpy(pnew_act, act, __sanitizer::struct_sigaction_sz);
+ uptr cb = __sanitizer::__sanitizer_get_sigaction_sa_sigaction(pnew_act);
+ uptr new_cb =
+ __sanitizer::__sanitizer_get_sigaction_sa_siginfo(pnew_act) ?
+ (uptr)SignalAction : (uptr)SignalHandler;
+ if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
+ sigactions[signo] = cb;
+ __sanitizer::__sanitizer_set_sigaction_sa_sigaction(pnew_act, new_cb);
+ }
}
+ res = REAL(sigaction)(signo, pnew_act, oldact);
+ if (res == 0 && oldact) {
+ __sanitizer::__sanitizer_set_sigaction_sa_sigaction(oldact, old_cb);
+ }
+ } else {
+ res = REAL(sigaction)(signo, act, oldact);
}
- int res = REAL(sigaction)(signo, pnew_act, oldact);
+
if (res == 0 && oldact) {
__msan_unpoison(oldact, __sanitizer::struct_sigaction_sz);
- __sanitizer::__sanitizer_set_sigaction_sa_sigaction(oldact, old_cb);
}
return res;
}
INTERCEPTOR(int, signal, int signo, uptr cb) {
ENSURE_MSAN_INITED();
- CHECK_LT(signo, kMaxSignals);
- SpinMutexLock lock(&sigactions_mu);
- if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
- sigactions[signo] = cb;
- cb = (uptr)SignalHandler;
+ if (flags()->wrap_signals) {
+ CHECK_LT(signo, kMaxSignals);
+ SpinMutexLock lock(&sigactions_mu);
+ if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
+ sigactions[signo] = cb;
+ cb = (uptr) SignalHandler;
+ }
+ return REAL(signal)(signo, cb);
+ } else {
+ return REAL(signal)(signo, cb);
}
- return REAL(signal)(signo, cb);
}
extern "C" int pthread_attr_init(void *attr);
More information about the llvm-commits
mailing list