• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t && \
2 // RUN:     MSAN_OPTIONS=store_context_size=1 not %run %t 2>&1 | FileCheck %s
3 
4 // Test that stack trace for the intermediate store is not empty.
5 
6 // CHECK: MemorySanitizer: use-of-uninitialized-value
7 // CHECK:   #0 {{.*}} in main
8 
9 // CHECK: Uninitialized value was stored to memory at
10 // CHECK:   #0 {{.*}} in fn_g
11 // CHECK-NOT: #1
12 
13 // CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main'
14 // CHECK:   #0 {{.*}} in main
15 
16 #include <stdio.h>
17 
18 volatile int x;
19 
20 __attribute__((noinline))
fn_g(int a)21 void fn_g(int a) {
22   x = a;
23 }
24 
25 __attribute__((noinline))
fn_f(int a)26 void fn_f(int a) {
27   fn_g(a);
28 }
29 
main(int argc,char * argv[])30 int main(int argc, char *argv[]) {
31   int volatile z;
32   fn_f(z);
33   return x;
34 }
35