[compiler-rt] r217137 - [ASan] allow deadly signals to be received in signal handlers
Alexander Potapenko
glider at google.com
Thu Sep 4 02:34:22 PDT 2014
Author: glider
Date: Thu Sep 4 04:34:22 2014
New Revision: 217137
URL: http://llvm.org/viewvc/llvm-project?rev=217137&view=rev
Log:
[ASan] allow deadly signals to be received in signal handlers
(previously ASan would just crash upon the second SEGV)
Other tools do not use this code yet.
Added:
compiler-rt/trunk/test/asan/TestCases/zero_page_pc.cc
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc?rev=217137&r1=217136&r2=217137&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc Thu Sep 4 04:34:22 2014
@@ -148,7 +148,9 @@ static void MaybeInstallSigaction(int si
struct sigaction sigact;
internal_memset(&sigact, 0, sizeof(sigact));
sigact.sa_sigaction = (sa_sigaction_t)handler;
- sigact.sa_flags = SA_SIGINFO;
+ // Do not block the signal from being received in that signal's handler.
+ // Clients are responsible for handling this correctly.
+ sigact.sa_flags = SA_SIGINFO | SA_NODEFER;
if (common_flags()->use_sigaltstack) sigact.sa_flags |= SA_ONSTACK;
CHECK_EQ(0, internal_sigaction(signum, &sigact, 0));
VReport(1, "Installed the sigaction for signal %d\n", signum);
Added: compiler-rt/trunk/test/asan/TestCases/zero_page_pc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/zero_page_pc.cc?rev=217137&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/zero_page_pc.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/zero_page_pc.cc Thu Sep 4 04:34:22 2014
@@ -0,0 +1,11 @@
+// Check that ASan correctly detects SEGV on the zero page.
+// RUN: %clangxx_asan %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+typedef void void_f();
+int main() {
+ void_f *func = (void_f *)0x7;
+ func();
+ // CHECK: {{AddressSanitizer: SEGV.*(pc.*0007)}}
+ // CHECK: AddressSanitizer: while reporting a bug found another one. Ignoring.
+ return 0;
+}
More information about the llvm-commits
mailing list