Home | History | Annotate | Download | only in lit_tests
      1 // Build a library with origin tracking and an executable w/o origin tracking.
      2 // Test that origin tracking is enabled at runtime.
      3 // RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %p/SharedLibs/dso-origin-so.cc \
      4 // RUN:     -fPIC -shared -o %t-so.so
      5 // RUN: %clangxx_msan -m64 -O0 %s %t-so.so -o %t && not %t 2>&1 | FileCheck %s
      6 
      7 #include <stdlib.h>
      8 
      9 #include "SharedLibs/dso-origin.h"
     10 
     11 int main(int argc, char **argv) {
     12   int *x = (int *)my_alloc(sizeof(int));
     13   my_access(x);
     14   delete x;
     15 
     16   // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
     17   // CHECK: {{#0 0x.* in my_access .*dso-origin-so.cc:}}
     18   // CHECK: {{#1 0x.* in main .*dso-origin.cc:}}[[@LINE-5]]
     19   // CHECK: Uninitialized value was created by a heap allocation
     20   // CHECK: {{#0 0x.* in .*malloc}}
     21   // CHECK: {{#1 0x.* in my_alloc .*dso-origin-so.cc:}}
     22   // CHECK: {{#2 0x.* in main .*dso-origin.cc:}}[[@LINE-10]]
     23   // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*dso-origin-so.cc:.* my_access}}
     24   return 0;
     25 }
     26