[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.

llvm-svn: 217137
This commit is contained in:
Alexander Potapenko 2014-09-04 09:34:22 +00:00
parent 2e5134f8f4
commit 9d24aa0fa8
2 changed files with 14 additions and 1 deletions

View File

@ -148,7 +148,9 @@ static void MaybeInstallSigaction(int signum,
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);

View File

@ -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;
}