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
13int 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(fds: nullptr, nfds: 0, timeout: &ts, ss: nullptr);
20 assert(res == 0);
21
22 if (T == 'A') {
23 __msan_poison(a: &ts.tv_sec, size: sizeof(ts.tv_sec));
24 ppoll(fds: nullptr, nfds: 0, timeout: &ts, ss: nullptr);
25 // A: use-of-uninitialized-value
26 }
27
28 // A-NOT: ==1
29 // B: ==1
30 fprintf(stderr, format: "==1\n");
31
32 sigset_t sig;
33 if (T != 'B')
34 sigemptyset(set: &sig);
35 ppoll(fds: nullptr, nfds: 0, timeout: &ts, ss: &sig);
36 // B: use-of-uninitialized-value
37
38 // B-NOT: ==2
39 // CLEAN: ==2
40 fprintf(stderr, format: "==2\n");
41 return 0;
42}
43

source code of compiler-rt/test/msan/Linux/poll.cpp