• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Check that stores in signal handlers are not recorded in origin history.
2 // This is, in fact, undesired behavior caused by our chained origins
3 // 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>&1
7 // RUN: FileCheck %s < %t.out
8 
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>&1
11 // RUN: FileCheck %s < %t.out
12 
13 #include <signal.h>
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include <unistd.h>
17 
18 volatile int x, y;
19 
SignalHandler(int signo)20 void SignalHandler(int signo) {
21   y = x;
22 }
23 
main(int argc,char * argv[])24 int main(int argc, char *argv[]) {
25   int volatile z;
26   x = z;
27 
28   signal(SIGHUP, SignalHandler);
29   kill(getpid(), SIGHUP);
30   signal(SIGHUP, SIG_DFL);
31 
32   return y;
33 }
34 
35 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
36 // CHECK-NOT: in SignalHandler
37