brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1016 B · 7319780 Raw
40 lines · cpp
1// Check that stores in signal handlers are not recorded in origin history.2// This is, in fact, undesired behavior caused by our chained origins3// implementation being not async-signal-safe.4 5// RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \6// RUN:     not %run %t >%t.out 2>&17// RUN: FileCheck %s < %t.out8 9// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t && \10// RUN:     not %run %t >%t.out 2>&111// RUN: FileCheck %s < %t.out12 13// Reported deadly signal due to stack-overflow14// XFAIL: target={{.*netbsd.*}}15 16#include <signal.h>17#include <stdio.h>18#include <sys/types.h>19#include <unistd.h>20 21volatile int x, y;22 23void SignalHandler(int signo) {24  y = x;25}26 27int main(int argc, char *argv[]) {28  int volatile z;29  x = z;30 31  signal(SIGHUP, SignalHandler);32  kill(getpid(), SIGHUP);33  signal(SIGHUP, SIG_DFL);34 35  return y;36}37 38// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value39// CHECK-NOT: in SignalHandler40