1 // RUN: %clang_dfsan -DUSE_SIGNAL_ACTION -Wno-error=int-conversion %s -o %t && %run %t
2 // RUN: %clang_dfsan -Wno-error=int-conversion %s -o %t && %run %t
4 #include <sanitizer/dfsan_interface.h>
15 void SignalHandler(int signo
) {
16 assert(dfsan_get_label(signo
) == 0);
20 void SignalAction(int signo
, siginfo_t
*si
, void *uc
) {
21 assert(dfsan_get_label(signo
) == 0);
22 assert(dfsan_get_label(si
) == 0);
23 assert(dfsan_get_label(uc
) == 0);
24 assert(0 == dfsan_read_label(si
, sizeof(*si
)));
25 assert(0 == dfsan_read_label(uc
, sizeof(ucontext_t
)));
29 int main(int argc
, char *argv
[]) {
30 dfsan_set_label(8, (void *)&z
, sizeof(z
));
32 struct sigaction sa
= {};
33 #ifdef USE_SIGNAL_ACTION
34 sa
.sa_flags
= SA_SIGINFO
;
35 sa
.sa_sigaction
= SignalAction
;
37 sa
.sa_handler
= SignalHandler
;
39 int r
= sigaction(SIGHUP
, &sa
, NULL
);
40 assert(dfsan_get_label(r
) == 0);
42 kill(getpid(), SIGHUP
);
43 signal(SIGHUP
, SIG_DFL
);