[llvm-commits] [compiler-rt] r154390 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc tests/asan_test.cc
Alexander Potapenko
glider at google.com
Tue Apr 10 04:00:26 PDT 2012
Author: glider
Date: Tue Apr 10 06:00:26 2012
New Revision: 154390
URL: http://llvm.org/viewvc/llvm-project?rev=154390&view=rev
Log:
Change the way ASan interacts with custom signal handlers.
>From now on we allow the clients to override signal handlers set by ASan, but print a warning in such a case.
Remove the tests for signal() and sigaction(), because they made little sense even without this change.
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/tests/asan_test.cc
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=154390&r1=154389&r2=154390&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Tue Apr 10 06:00:26 2012
@@ -339,19 +339,21 @@
#endif // !_WIN32
#if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
+const char kOverrideSighandlerWarning[] =
+ "Warning: client program overrides the handler for signal %d.\n";
INTERCEPTOR(void*, signal, int signum, void *handler) {
- if (!AsanInterceptsSignal(signum)) {
- return REAL(signal)(signum, handler);
+ if (AsanInterceptsSignal(signum)) {
+ Report(kOverrideSighandlerWarning, signum);
}
- return NULL;
+ return REAL(signal)(signum, handler);
}
INTERCEPTOR(int, sigaction, int signum, const struct sigaction *act,
struct sigaction *oldact) {
- if (!AsanInterceptsSignal(signum)) {
- return REAL(sigaction)(signum, act, oldact);
+ if (AsanInterceptsSignal(signum)) {
+ Report(kOverrideSighandlerWarning, signum);
}
- return 0;
+ return REAL(sigaction)(signum, act, oldact);
}
#elif ASAN_POSIX
// We need to have defined REAL(sigaction) on posix systems.
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=154390&r1=154389&r2=154390&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Tue Apr 10 06:00:26 2012
@@ -210,48 +210,6 @@
}
#endif // __APPLE__
-void NoOpSignalHandler(int unused) {
- fprintf(stderr, "NoOpSignalHandler (should not happen). Aborting\n");
- abort();
-}
-
-void NoOpSigaction(int, siginfo_t *siginfo, void *context) {
- fprintf(stderr, "NoOpSigaction (should not happen). Aborting\n");
- abort();
-}
-
-TEST(AddressSanitizer, SignalTest) {
- signal(SIGSEGV, NoOpSignalHandler);
- signal(SIGILL, NoOpSignalHandler);
- // If asan did not intercept sigaction NoOpSigaction will fire.
- char *x = Ident((char*)malloc(5));
- EXPECT_DEATH(x[6]++, "is located 1 bytes to the right");
- free(Ident(x));
-}
-
-TEST(AddressSanitizer, SigactionTest) {
- {
- struct sigaction sigact;
- memset(&sigact, 0, sizeof(sigact));
- sigact.sa_sigaction = NoOpSigaction;;
- sigact.sa_flags = SA_SIGINFO;
- sigaction(SIGSEGV, &sigact, 0);
- }
-
- {
- struct sigaction sigact;
- memset(&sigact, 0, sizeof(sigact));
- sigact.sa_sigaction = NoOpSigaction;;
- sigact.sa_flags = SA_SIGINFO;
- sigaction(SIGILL, &sigact, 0);
- }
-
- // If asan did not intercept sigaction NoOpSigaction will fire.
- char *x = Ident((char*)malloc(5));
- EXPECT_DEATH(x[6]++, "is located 1 bytes to the right");
- free(Ident(x));
-}
-
void *TSDWorker(void *test_key) {
if (test_key) {
pthread_setspecific(*(pthread_key_t*)test_key, (void*)0xfeedface);
More information about the llvm-commits
mailing list