1 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -std=c++11 -O0 %s -o %t && %run %t
3 // Test that va_arg shadow from a signal handler does not leak outside.
5 // Reported deadly signal due to stack-overflow
6 // XFAIL: target={{.*netbsd.*}}
10 #include <sanitizer/msan_interface.h>
15 const int kSigCnt
= 200;
17 void f(bool poisoned
, int n
, ...) {
20 for (int i
= 0; i
< n
; ++i
) {
21 void *p
= va_arg(vl
, void *);
23 assert(__msan_test_shadow(&p
, sizeof(p
)) == -1);
30 void SignalHandler(int signo
) {
31 assert(signo
== SIGPROF
);
33 void **volatile q
= &p
;
41 signal(SIGPROF
, SignalHandler
);
44 itv
.it_interval
.tv_sec
= 0;
45 itv
.it_interval
.tv_usec
= 100;
46 itv
.it_value
.tv_sec
= 0;
47 itv
.it_value
.tv_usec
= 100;
48 setitimer(ITIMER_PROF
, &itv
, NULL
);
51 void **volatile q
= &p
;
55 nullptr, nullptr, nullptr, nullptr, nullptr,
56 nullptr, nullptr, nullptr, nullptr, nullptr,
57 nullptr, nullptr, nullptr, nullptr, nullptr,
58 nullptr, nullptr, nullptr, nullptr, nullptr);
64 } while (sigcnt
< kSigCnt
);
66 itv
.it_interval
.tv_sec
= 0;
67 itv
.it_interval
.tv_usec
= 0;
68 itv
.it_value
.tv_sec
= 0;
69 itv
.it_value
.tv_usec
= 0;
70 setitimer(ITIMER_PROF
, &itv
, NULL
);
72 signal(SIGPROF
, SIG_DFL
);