[compiler-rt] r317970 - [msan] Fix signal chaining

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 19:03:34 PST 2017


Author: vitalybuka
Date: Fri Nov 10 19:03:34 2017
New Revision: 317970

URL: http://llvm.org/viewvc/llvm-project?rev=317970&view=rev
Log:
[msan] Fix signal chaining

Return internally stored handlers only if handlers is set to wrapper

Modified:
    compiler-rt/trunk/lib/msan/msan_interceptors.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.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=317970&r1=317969&r2=317970&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Nov 10 19:03:34 2017
@@ -1301,7 +1301,7 @@ static int sigaction_impl(int signo, con
     res = REAL(sigaction)(signo, pnew_act, oldact);
     if (res == 0 && oldact) {
       uptr cb = (uptr)oldact->sigaction;
-      if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
+      if (cb == (uptr)SignalAction || cb == (uptr)SignalHandler) {
         oldact->sigaction = (decltype(oldact->sigaction))old_cb;
       }
     }

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc?rev=317970&r1=317969&r2=317970&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc Fri Nov 10 19:03:34 2017
@@ -18,7 +18,7 @@
 // clang-format on
 
 // Remove when fixed: https://github.com/google/sanitizers/issues/637
-// XFAIL: msan
+
 // XFAIL: tsan
 
 // Flaky errors in debuggerd with "waitpid returned unexpected pid (0)" in logcat.
@@ -33,7 +33,7 @@ struct sigaction original_sigaction_sigs
 
 void User_OnSIGSEGV(int signum, siginfo_t *siginfo, void *context) {
   fprintf(stderr, "User sigaction called\n");
-  struct sigaction original_sigaction;
+  struct sigaction original_sigaction = {};
   if (signum == SIGBUS)
     original_sigaction = original_sigaction_sigbus;
   else if (signum == SIGSEGV)
@@ -58,7 +58,7 @@ int DoSEGV() {
 }
 
 bool InstallHandler(int signum, struct sigaction *original_sigaction) {
-  struct sigaction user_sigaction;
+  struct sigaction user_sigaction = {};
   user_sigaction.sa_sigaction = User_OnSIGSEGV;
   user_sigaction.sa_flags = SA_SIGINFO;
   if (sigaction(signum, &user_sigaction, original_sigaction)) {




More information about the llvm-commits mailing list