summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-06-02 21:32:04 +0000
committerKostya Serebryany <kcc@google.com>2017-06-02 21:32:04 +0000
commit8c2855d2320ab8a951a09e50195bd94ba19fcfe5 (patch)
tree23422884dcc63a22ac940cf397e89575186f9703 /test
parent66ccf00796296ff1e791e4f385ae487202617b65 (diff)
[asan] fix one more case where stack-use-after-return is not async-signal-safe (during thread startup). beef-up the test to give it a chance to catch regressions. Also relax the lint to make C++11 more usable.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304598 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/asan/TestCases/Linux/uar_signals.cc33
1 files changed, 20 insertions, 13 deletions
diff --git a/test/asan/TestCases/Linux/uar_signals.cc b/test/asan/TestCases/Linux/uar_signals.cc
index f42c3f666..f96a2fecb 100644
--- a/test/asan/TestCases/Linux/uar_signals.cc
+++ b/test/asan/TestCases/Linux/uar_signals.cc
@@ -1,12 +1,13 @@
// This test checks that the implementation of use-after-return
// is async-signal-safe.
-// RUN: %clangxx_asan -O1 %s -o %t -pthread && %run %t
+// RUN: %clangxx_asan -std=c++11 -O1 %s -o %t -pthread && %run %t
// REQUIRES: stable-runtime
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <pthread.h>
+#include <initializer_list>
int *g;
int n_signals;
@@ -17,7 +18,6 @@ void SignalHandler(int, siginfo_t*, void*) {
int local;
g = &local;
n_signals++;
- // printf("s: %p\n", &local);
}
static void EnableSigprof(Sigaction SignalHandler) {
@@ -49,22 +49,29 @@ void RecursiveFunction(int depth) {
RecursiveFunction(depth - 1);
}
-void *Thread(void *) {
- RecursiveFunction(18);
+void *FastThread(void *) {
+ RecursiveFunction(1);
+ return NULL;
+}
+
+void *SlowThread(void *) {
+ RecursiveFunction(1);
return NULL;
}
int main(int argc, char **argv) {
EnableSigprof(SignalHandler);
- for (int i = 0; i < 4; i++) {
- fprintf(stderr, ".");
- const int kNumThread = sizeof(void*) == 8 ? 16 : 8;
- pthread_t t[kNumThread];
- for (int i = 0; i < kNumThread; i++)
- pthread_create(&t[i], 0, Thread, 0);
- for (int i = 0; i < kNumThread; i++)
- pthread_join(t[i], 0);
+ for (auto Thread : {&FastThread, &SlowThread}) {
+ for (int i = 0; i < 1000; i++) {
+ fprintf(stderr, ".");
+ const int kNumThread = sizeof(void*) == 8 ? 32 : 8;
+ pthread_t t[kNumThread];
+ for (int i = 0; i < kNumThread; i++)
+ pthread_create(&t[i], 0, Thread, 0);
+ for (int i = 0; i < kNumThread; i++)
+ pthread_join(t[i], 0);
+ }
+ fprintf(stderr, "\n");
}
- fprintf(stderr, "\n");
}