1*7c3d14c8STreehugger Robot // Check that without suppressions, we catch the issue. 2*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t 3*7c3d14c8STreehugger Robot // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s 4*7c3d14c8STreehugger Robot 5*7c3d14c8STreehugger Robot // If the executable is started from a different location, we should still 6*7c3d14c8STreehugger Robot // find the suppression file located relative to the location of the executable. 7*7c3d14c8STreehugger Robot // RUN: rm -rf %T/suppressions-exec-relative-location 8*7c3d14c8STreehugger Robot // RUN: mkdir -p %T/suppressions-exec-relative-location 9*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %T/suppressions-exec-relative-location/exec 10*7c3d14c8STreehugger Robot // RUN: echo "interceptor_via_fun:crash_function" > \ 11*7c3d14c8STreehugger Robot // RUN: %T/suppressions-exec-relative-location/supp.txt 12*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=suppressions='"supp.txt"' \ 13*7c3d14c8STreehugger Robot // RUN: %run %T/suppressions-exec-relative-location/exec 2>&1 | \ 14*7c3d14c8STreehugger Robot // RUN: FileCheck --check-prefix=CHECK-IGNORE %s 15*7c3d14c8STreehugger Robot // RUN: rm -rf %T/suppressions-exec-relative-location 16*7c3d14c8STreehugger Robot 17*7c3d14c8STreehugger Robot // If the wrong absolute path is given, we don't try to construct 18*7c3d14c8STreehugger Robot // a relative path with it. 19*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=suppressions='"/absolute/path"' not %run %t 2>&1 | \ 20*7c3d14c8STreehugger Robot // RUN: FileCheck --check-prefix=CHECK-WRONG-FILE-NAME %s 21*7c3d14c8STreehugger Robot 22*7c3d14c8STreehugger Robot // Test that we reject directory as filename. 23*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=suppressions='"folder/only/"' not %run %t 2>&1 | \ 24*7c3d14c8STreehugger Robot // RUN: FileCheck --check-prefix=CHECK-WRONG-FILE-NAME %s 25*7c3d14c8STreehugger Robot 26*7c3d14c8STreehugger Robot // XFAIL: android 27*7c3d14c8STreehugger Robot // XFAIL: win32 28*7c3d14c8STreehugger Robot 29*7c3d14c8STreehugger Robot #include <stdio.h> 30*7c3d14c8STreehugger Robot #include <stdlib.h> 31*7c3d14c8STreehugger Robot #include <string.h> 32*7c3d14c8STreehugger Robot crash_function()33*7c3d14c8STreehugger Robotvoid crash_function() { 34*7c3d14c8STreehugger Robot char *a = (char *)malloc(6); 35*7c3d14c8STreehugger Robot free(a); 36*7c3d14c8STreehugger Robot size_t len = strlen(a); // BOOM 37*7c3d14c8STreehugger Robot fprintf(stderr, "strlen ignored, len = %zu\n", len); 38*7c3d14c8STreehugger Robot } 39*7c3d14c8STreehugger Robot main()40*7c3d14c8STreehugger Robotint main() { 41*7c3d14c8STreehugger Robot crash_function(); 42*7c3d14c8STreehugger Robot } 43*7c3d14c8STreehugger Robot 44*7c3d14c8STreehugger Robot // CHECK-CRASH: AddressSanitizer: heap-use-after-free 45*7c3d14c8STreehugger Robot // CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow 46*7c3d14c8STreehugger Robot // CHECK-IGNORE: ignored 47*7c3d14c8STreehugger Robot // CHECK-WRONG-FILE-NAME: failed to read suppressions file 48