[PATCH] D39935: [tsan] Fix signal chaining

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 12:49:28 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL318082: [tsan] Fix signal chaining (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D39935?vs=122569&id=122706#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39935

Files:
  compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
  compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc


Index: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
@@ -2276,7 +2276,8 @@
   // The handler will run synchronously and corrupt tsan per-thread state.
   SCOPED_INTERCEPTOR_RAW(sigaction, sig, act, old);
   __sanitizer_sigaction *sigactions = interceptor_ctx()->sigactions;
-  if (old) internal_memcpy(old, &sigactions[sig], sizeof(*old));
+  __sanitizer_sigaction old_stored;
+  internal_memcpy(&old_stored, &sigactions[sig], sizeof(old_stored));
   if (act == 0) return 0;
   // Copy act into sigactions[sig].
   // Can't use struct copy, because compiler can emit call to memcpy.
@@ -2302,7 +2303,13 @@
       newact.handler = rtl_sighandler;
   }
   ReleaseStore(thr, pc, (uptr)&sigactions[sig]);
-  int res = REAL(sigaction)(sig, &newact, 0);
+  int res = REAL(sigaction)(sig, &newact, old);
+  if (res == 0 && old) {
+    uptr cb = (uptr)old->sigaction;
+    if (cb == (uptr)rtl_sigaction || cb == (uptr)rtl_sighandler) {
+      internal_memcpy(old, &old_stored, sizeof(*old));
+    }
+  }
   return res;
 }
 
Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc
===================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc
@@ -17,10 +17,6 @@
 // RUN: %env_tool_opts=handle_segv=2:allow_user_segv_handler=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2
 // clang-format on
 
-// Remove when fixed: https://github.com/google/sanitizers/issues/637
-
-// XFAIL: tsan
-
 // Flaky errors in debuggerd with "waitpid returned unexpected pid (0)" in logcat.
 // UNSUPPORTED: android && i386-target-arch
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39935.122706.patch
Type: text/x-patch
Size: 1891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171113/0c02370a/attachment.bin>


More information about the llvm-commits mailing list