1 // RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t
2 // RUN: %run %t __
3 // RUN: not %run %t A_ 2>&1 | FileCheck %s
4 // RUN: not %run %t AH 2>&1 | FileCheck %s
5 // RUN: not %run %t B_ 2>&1 | FileCheck %s
6 // RUN: not %run %t BH 2>&1 | FileCheck %s
7 // RUN: not %run %t C_ 2>&1 | FileCheck %s
8 // RUN: not %run %t CH 2>&1 | FileCheck %s
9
10 #include <assert.h>
11 #include <signal.h>
12 #include <string.h>
13 #include <sys/time.h>
14 #include <unistd.h>
15
16 #include <sanitizer/msan_interface.h>
17
handler(int)18 void handler(int) {}
action(int,siginfo_t *,void *)19 void action(int, siginfo_t *, void *) {}
20
main(int argc,char ** argv)21 int main(int argc, char **argv) {
22 char T = argv[1][0];
23 char H = argv[1][1];
24 struct sigaction sa;
25 memset(&sa, 0, sizeof(sa));
26 if (H == 'H') {
27 sa.sa_handler = handler;
28 } else {
29 sa.sa_sigaction = action;
30 sa.sa_flags = SA_SIGINFO;
31 }
32
33 if (T == 'A') {
34 if (H == 'H')
35 __msan_poison(&sa.sa_handler, sizeof(sa.sa_handler));
36 else
37 __msan_poison(&sa.sa_sigaction, sizeof(sa.sa_sigaction));
38 }
39 if (T == 'B')
40 __msan_poison(&sa.sa_flags, sizeof(sa.sa_flags));
41 if (T == 'C')
42 __msan_poison(&sa.sa_mask, sizeof(sa.sa_mask));
43 // CHECK: use-of-uninitialized-value
44 int res = sigaction(SIGUSR1, &sa, nullptr);
45 assert(res == 0);
46 return 0;
47 }
48