diff options
author | Vitaly Buka <vitalybuka@google.com> | 2017-11-20 23:37:46 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2017-11-20 23:37:46 +0000 |
commit | 425a276f1ad02b7e08a41d667475838e848b5a53 (patch) | |
tree | ce111fffbcb0ab12173dd4268b9338eda1c13d8f /test | |
parent | c3efd8d451dc3d8d2c932cf8082c26ed1be0629d (diff) |
[tsan] Fix sigaction implementation when it's called only to get handler
Reviewers: eugenis
Subscribers: kubamracek, llvm-commits, krytarowski
Differential Revision: https://reviews.llvm.org/D40272
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318707 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc b/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc index 51e8bdb6e..d6c3ecbff 100644 --- a/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc +++ b/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc @@ -1,4 +1,6 @@ -// RUN: %clangxx -O1 %s -o %t && TSAN_OPTIONS="flush_memory_ms=1 memory_limit_mb=1" ASAN_OPTIONS="handle_segv=0" %run %t 2>&1 | FileCheck %s +// clang-format off +// RUN: %clangxx -O1 %s -o %t && TSAN_OPTIONS="flush_memory_ms=1 memory_limit_mb=1" %run %t 2>&1 | FileCheck %s +// clang-format on // JVM uses SEGV to preempt threads. All threads do a load from a known address // periodically. When runtime needs to preempt threads, it unmaps the page. @@ -13,11 +15,12 @@ // "benign" SEGVs that are handled by signal handler, and ensures that // the process survive. +#include <assert.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> -#include <sys/mman.h> #include <string.h> +#include <sys/mman.h> #include <unistd.h> unsigned long page_size; @@ -35,6 +38,12 @@ int main() { a.sa_sigaction = handler; a.sa_flags = SA_SIGINFO; sigaction(SIGSEGV, &a, &old); + + memset(&a, 0, sizeof(a)); + sigaction(SIGSEGV, 0, &a); + assert(a.sa_sigaction == handler); + assert(a.sa_flags & SA_SIGINFO); + guard = mmap(0, 3 * page_size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); guard = (char*)guard + page_size; // work around a kernel bug for (int i = 0; i < 1000000; i++) { |