diff options
author | Derek Bruening <bruening@google.com> | 2016-07-06 21:04:48 +0000 |
---|---|---|
committer | Derek Bruening <bruening@google.com> | 2016-07-06 21:04:48 +0000 |
commit | 3df39427e495cb2ae84b9d7fc8541d4601f7b597 (patch) | |
tree | 7f4a0a5a7f6cb3aa17e1250fb82cf2c4891f1f4e /test/esan | |
parent | ccf627eb417a383adffda4d894a3776792bbbf4c (diff) |
[esan|wset] Ensure SIGSEGV is not blocked
Summary:
Adds interception of sigprocmask and pthread_sigmask to esan so that the
working set tool can prevent SIGSEGV from being blocked. A blocked SIGSEGV
results in crashes due to our lazy shadow page allocation scheme.
Adds new sanitizer helper functions internal_sigemptyset and
internal_sigismember.
Adds a test to workingset-signal-posix.cpp.
Reviewers: aizatsky
Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka
Differential Revision: http://reviews.llvm.org/D22063
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/esan')
-rw-r--r-- | test/esan/TestCases/workingset-signal-posix.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/test/esan/TestCases/workingset-signal-posix.cpp b/test/esan/TestCases/workingset-signal-posix.cpp index fe7ced0cc..ba776fc02 100644 --- a/test/esan/TestCases/workingset-signal-posix.cpp +++ b/test/esan/TestCases/workingset-signal-posix.cpp @@ -1,11 +1,12 @@ // RUN: %clang_esan_wset -O0 %s -o %t 2>&1 // RUN: %run %t 2>&1 | FileCheck %s +#include <assert.h> +#include <setjmp.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> -#include <setjmp.h> -#include <assert.h> +#include <sys/mman.h> sigjmp_buf mark; @@ -51,10 +52,24 @@ int main(int argc, char **argv) { assert(Res == 0); assert(SigAct.sa_sigaction == SigactionHandler); + // Test blocking SIGSEGV and raising a shadow fault. + sigset_t Set; + sigemptyset(&Set); + sigaddset(&Set, SIGSEGV); + Res = sigprocmask(SIG_BLOCK, &Set, NULL); + // Make a large enough mapping that its start point will be before any + // prior library-region shadow access. + char *buf = (char *)mmap(0, 640*1024, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + buf[0] = 4; + munmap(buf, 640*1024); + fprintf(stderr, "Past blocked-SIGSEGV shadow fault\n"); + return 0; } // CHECK: Handling SIGSEGV for signal // CHECK-NEXT: Past longjmp for signal // CHECK-NEXT: Handling SIGSEGV for sigaction // CHECK-NEXT: Past longjmp for sigaction -// CHECK: {{.*}} EfficiencySanitizer: the total working set size: {{[0-9][0-9][0-9]}} Bytes ({{[0-9][0-9]}} cache lines) +// CHECK-NEXT: Past blocked-SIGSEGV shadow fault +// CHECK: {{.*}} EfficiencySanitizer: the total working set size: {{[0-9]+}} Bytes ({{[0-9][0-9]}} cache lines) |