blob: aa91d1ddeb101cc01aa4e4a4db21fd61479e2de5 [file] [log] [blame]
Stephen Hines86277eb2015-03-23 12:06:32 -07001// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08002// UNSUPPORTED: darwin
Stephen Hines86277eb2015-03-23 12:06:32 -07003#include <pthread.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <signal.h>
7#include <sys/types.h>
8#include <sys/time.h>
9#include <unistd.h>
10#include <errno.h>
11
12volatile int X;
13
14static void handler(int sig) {
15 (void)sig;
16 if (X != 0)
17 printf("bad");
18}
19
20static void* thr(void *p) {
21 return 0;
22}
23
24int main() {
25 struct sigaction act = {};
26 act.sa_handler = &handler;
27 if (sigaction(SIGPROF, &act, 0)) {
28 perror("sigaction");
29 exit(1);
30 }
31
32 itimerval t;
33 t.it_value.tv_sec = 0;
34 t.it_value.tv_usec = 10;
35 t.it_interval = t.it_value;
36 if (setitimer(ITIMER_PROF, &t, 0)) {
37 perror("setitimer");
38 exit(1);
39 }
40
41 for (int i = 0; i < 10000; i++) {
42 pthread_t th;
43 pthread_create(&th, 0, thr, 0);
44 pthread_join(th, 0);
45 }
46
47 fprintf(stderr, "DONE\n");
48 return 0;
49}
50
51// CHECK-NOT: WARNING: ThreadSanitizer:
52// CHECK: DONE
53// CHECK-NOT: WARNING: ThreadSanitizer: