brintos

brintos / llvm-project-archived public Read only

0
0
Text · 929 B · 7870d18 Raw
43 lines · cpp
1// RUN: %clangxx_msan -O0 -std=c++11 -g %s -o %t2// RUN: %run %t _ 2>&1 | FileCheck %s --check-prefix=CLEAN3// RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=A4// RUN: not %run %t B 2>&1 | FileCheck %s --check-prefix=B5 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(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-value26  }27 28  // A-NOT: ==129  // B: ==130  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-value37 38  // B-NOT: ==239  // CLEAN: ==240  fprintf(stderr, "==2\n");41  return 0;42}43