[PATCH] D68604: [tsan] Don't delay SIGTRAP handler
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 15:18:13 PDT 2019
vitalybuka created this revision.
vitalybuka added a reviewer: eugenis.
Herald added a reviewer: jfb.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D68604
Files:
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
compiler-rt/test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp
Index: compiler-rt/test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp
===================================================================
--- /dev/null
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/signal_trap_handler.cpp
@@ -0,0 +1,31 @@
+// RUN: %clangxx -O1 %s -o %t && %env_tool_opts=handle_sigtrap=2 not %run %t 2>&1 | FileCheck %s
+
+#include <assert.h>
+#include <signal.h>
+#include <stdio.h>
+
+int handled;
+
+void handler(int signo, siginfo_t *info, void *uctx) {
+ handled = 1;
+}
+
+int main() {
+ struct sigaction a = {}, old = {};
+ a.sa_sigaction = handler;
+ a.sa_flags = SA_SIGINFO;
+ sigaction(SIGTRAP, &a, &old);
+
+ a = {};
+ sigaction(SIGTRAP, 0, &a);
+ assert(a.sa_sigaction == handler);
+ assert(a.sa_flags & SA_SIGINFO);
+
+ __builtin_debugtrap();
+ assert(handled);
+ fprintf(stderr, "HANDLED %d\n", handled);
+
+ sigaction(SIGTRAP, &old, 0);
+}
+
+// CHECK: HANDLED 1
Index: compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
===================================================================
--- compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -114,6 +114,7 @@
const int EPOLL_CTL_ADD = 1;
#endif
const int SIGILL = 4;
+const int SIGTRAP = 5;
const int SIGABRT = 6;
const int SIGFPE = 8;
const int SIGSEGV = 11;
@@ -1962,10 +1963,10 @@
} // namespace __tsan
static bool is_sync_signal(ThreadSignalContext *sctx, int sig) {
- return sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
- sig == SIGABRT || sig == SIGFPE || sig == SIGPIPE || sig == SIGSYS ||
- // If we are sending signal to ourselves, we must process it now.
- (sctx && sig == sctx->int_signal_send);
+ return sig == SIGSEGV || sig == SIGBUS || sig == SIGILL || sig == SIGTRAP ||
+ sig == SIGABRT || sig == SIGFPE || sig == SIGPIPE || sig == SIGSYS ||
+ // If we are sending signal to ourselves, we must process it now.
+ (sctx && sig == sctx->int_signal_send);
}
void ALWAYS_INLINE rtl_generic_sighandler(bool sigact, int sig,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68604.223675.patch
Type: text/x-patch
Size: 2077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191007/5f76f376/attachment.bin>
More information about the llvm-commits
mailing list