[compiler-rt] r178868 - [msan] Fix sigaction interceptor.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Apr 5 05:58:07 PDT 2013
Author: eugenis
Date: Fri Apr 5 07:58:07 2013
New Revision: 178868
URL: http://llvm.org/viewvc/llvm-project?rev=178868&view=rev
Log:
[msan] Fix sigaction interceptor.
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.cc
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=178868&r1=178867&r2=178868&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Apr 5 07:58:07 2013
@@ -868,7 +868,10 @@ INTERCEPTOR(int, sigaction, int signo, c
}
res = REAL(sigaction)(signo, pnew_act, oldact);
if (res == 0 && oldact) {
- __sanitizer::__sanitizer_set_sigaction_sa_sigaction(oldact, old_cb);
+ uptr cb = __sanitizer::__sanitizer_get_sigaction_sa_sigaction(oldact);
+ if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
+ __sanitizer::__sanitizer_set_sigaction_sa_sigaction(oldact, old_cb);
+ }
}
} else {
res = REAL(sigaction)(signo, act, oldact);
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=178868&r1=178867&r2=178868&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Fri Apr 5 07:58:07 2013
@@ -981,6 +981,7 @@ void SigactionHandler(int signo, siginfo
TEST(MemorySanitizer, sigaction) {
struct sigaction act = {};
+ struct sigaction oldact = {};
act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = &SigactionHandler;
sigaction(SIGPROF, &act, 0);
@@ -993,17 +994,23 @@ TEST(MemorySanitizer, sigaction) {
act.sa_flags &= ~SA_SIGINFO;
act.sa_handler = SIG_IGN;
- sigaction(SIGPROF, &act, 0);
+ sigaction(SIGPROF, &act, &oldact);
+ EXPECT_FALSE(oldact.sa_flags & SA_SIGINFO);
+ EXPECT_EQ(SIG_DFL, oldact.sa_handler);
kill(getpid(), SIGPROF);
act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = &SigactionHandler;
- sigaction(SIGPROF, &act, 0);
+ sigaction(SIGPROF, &act, &oldact);
+ EXPECT_FALSE(oldact.sa_flags & SA_SIGINFO);
+ EXPECT_EQ(SIG_IGN, oldact.sa_handler);
kill(getpid(), SIGPROF);
act.sa_flags &= ~SA_SIGINFO;
act.sa_handler = SIG_DFL;
- sigaction(SIGPROF, &act, 0);
+ sigaction(SIGPROF, &act, &oldact);
+ EXPECT_TRUE(oldact.sa_flags & SA_SIGINFO);
+ EXPECT_EQ(&SigactionHandler, oldact.sa_sigaction);
EXPECT_EQ(2, cnt);
}
More information about the llvm-commits
mailing list