1 // Check that without suppressions, we catch the issue. 2 // RUN: %clangxx_asan -O0 %s -o %t 3 // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s 4 5 // RUN: echo "interceptor_via_fun:crash_function" > %t.supp 6 // RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s 7 // RUN: %clangxx_asan -O3 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s 8 9 // FIXME: Windows symbolizer needs work to make this pass. 10 // XFAIL: android,windows-msvc 11 // UNSUPPORTED: ios 12 13 // FIXME: atos does not work for inlined functions, yet llvm-symbolizer 14 // does not always work with debug info on Darwin. 15 // UNSUPPORTED: darwin 16 17 #include <stdio.h> 18 #include <stdlib.h> 19 #include <string.h> 20 21 void crash_function() { 22 char *a = (char *)malloc(6); 23 free(a); 24 size_t len = strlen(a); // BOOM 25 fprintf(stderr, "strlen ignored, len = %zu\n", len); 26 } 27 28 int main() { 29 crash_function(); 30 } 31 32 // CHECK-CRASH: AddressSanitizer: heap-use-after-free 33 // CHECK-CRASH-NOT: strlen ignored 34 // CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free 35 // CHECK-IGNORE: strlen ignored 36