1 // Stress test of poisoning from signal handler.
3 // RUN: %clangxx_msan -std=c++11 -O2 %s -o %t && %run %t
4 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -std=c++11 -O2 %s -o %t && %run %t
5 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -fsanitize-memory-use-after-dtor -std=c++11 -O2 %s -o %t && %run %t
13 #include <sanitizer/msan_interface.h>
15 std::atomic
<int> n
= {1000};
22 __attribute__((noinline
, optnone
)) void Poison() {
26 __msan_poison(&t
, sizeof(t
));
31 for (int i
= 0; i
< 1000; i
++) {
43 int main(int argc
, char **argv
) {
44 const int kThreads
= 10;
45 pthread_t th
[kThreads
];
46 for (int i
= 0; i
< kThreads
; i
++)
47 pthread_create(&th
[i
], 0, thr
, 0);
49 struct sigaction sa
= {};
50 sa
.sa_handler
= handler
;
51 assert(!sigaction(SIGPROF
, &sa
, 0));
54 t
.it_value
.tv_sec
= 0;
55 t
.it_value
.tv_usec
= 10;
56 t
.it_interval
= t
.it_value
;
57 assert(!setitimer(ITIMER_PROF
, &t
, 0));
59 for (int i
= 0; i
< kThreads
; i
++)
60 pthread_join(th
[i
], 0);