1 // RUN: %clangxx_dfsan %s -o %t && %run %t
2 // RUN: %clangxx_dfsan -mllvm -dfsan-track-origins=1 %s -o %t && %run %t
3 // RUN: %clangxx_dfsan -mllvm -dfsan-track-origins=1 -mllvm -dfsan-instrument-with-call-threshold=0 %s -o %t && %run %t
5 // Test that the state of shadows from a sigaction handler are consistent.
9 #include <sanitizer/dfsan_interface.h>
14 const int kSigCnt
= 200;
17 __attribute__((noinline
))
22 __attribute__((noinline
))
25 const dfsan_label r_label
= dfsan_get_label(r
);
26 assert(r_label
== 8 || r_label
== 0);
32 void SignalHandler(int signo
) {
33 assert(signo
== SIGPROF
);
35 dfsan_set_label(4, &a
, sizeof(a
));
41 struct sigaction psa
= {};
42 psa
.sa_handler
= SignalHandler
;
43 int r
= sigaction(SIGPROF
, &psa
, NULL
);
46 itv
.it_interval
.tv_sec
= 0;
47 itv
.it_interval
.tv_usec
= 100;
48 itv
.it_value
.tv_sec
= 0;
49 itv
.it_value
.tv_usec
= 100;
50 setitimer(ITIMER_PROF
, &itv
, NULL
);
52 dfsan_set_label(8, &x
, sizeof(x
));
55 } while (sigcnt
< kSigCnt
);
57 itv
.it_interval
.tv_sec
= 0;
58 itv
.it_interval
.tv_usec
= 0;
59 itv
.it_value
.tv_sec
= 0;
60 itv
.it_value
.tv_usec
= 0;
61 setitimer(ITIMER_PROF
, &itv
, NULL
);
63 signal(SIGPROF
, SIG_DFL
);