summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tsan/rtl/tsan_interceptors.cc11
-rw-r--r--test/sanitizer_common/TestCases/Linux/allow_user_segv.cc4
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/tsan/rtl/tsan_interceptors.cc b/lib/tsan/rtl/tsan_interceptors.cc
index d7b3f5f01..eb51a0a4e 100644
--- a/lib/tsan/rtl/tsan_interceptors.cc
+++ b/lib/tsan/rtl/tsan_interceptors.cc
@@ -2276,7 +2276,8 @@ int sigaction_impl(int sig, const __sanitizer_sigaction *act,
// 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 @@ int sigaction_impl(int sig, const __sanitizer_sigaction *act,
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;
}
diff --git a/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc b/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc
index 70710e34c..e17de1853 100644
--- a/test/sanitizer_common/TestCases/Linux/allow_user_segv.cc
+++ b/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