1 // RUN: %clangxx_msan -O0 -std=c++11 -g %s -o %t
2 // RUN: %run %t _ 2>&1 | FileCheck %s --check-prefix=CLEAN
3 // RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=A
4 // RUN: not %run %t B 2>&1 | FileCheck %s --check-prefix=B
5
6 #include <assert.h>
7 #include <poll.h>
8 #include <signal.h>
9 #include <stdio.h>
10
11 #include <sanitizer/msan_interface.h>
12
main(int argc,char ** argv)13 int main(int argc, char **argv) {
14 char T = argv[1][0];
15
16 struct timespec ts;
17 ts.tv_sec = 0;
18 ts.tv_nsec = 1000;
19 int res = ppoll(nullptr, 0, &ts, nullptr);
20 assert(res == 0);
21
22 if (T == 'A') {
23 __msan_poison(&ts.tv_sec, sizeof(ts.tv_sec));
24 ppoll(nullptr, 0, &ts, nullptr);
25 // A: use-of-uninitialized-value
26 }
27
28 // A-NOT: ==1
29 // B: ==1
30 fprintf(stderr, "==1\n");
31
32 sigset_t sig;
33 if (T != 'B')
34 sigemptyset(&sig);
35 ppoll(nullptr, 0, &ts, &sig);
36 // B: use-of-uninitialized-value
37
38 // B-NOT: ==2
39 // CLEAN: ==2
40 fprintf(stderr, "==2\n");
41 return 0;
42 }
43