Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 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 |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 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 |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 8 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 9 | // FIXME: Windows symbolizer needs work to make this pass. |
| 10 | // XFAIL: android,win32 |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 11 | |
| 12 | #include <stdio.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
| 15 | |
| 16 | void crash_function() { |
| 17 | char *a = (char *)malloc(6); |
| 18 | free(a); |
| 19 | size_t len = strlen(a); // BOOM |
| 20 | fprintf(stderr, "strlen ignored, len = %zu\n", len); |
| 21 | } |
| 22 | |
| 23 | int main() { |
| 24 | crash_function(); |
| 25 | } |
| 26 | |
| 27 | // CHECK-CRASH: AddressSanitizer: heap-use-after-free |
| 28 | // CHECK-CRASH-NOT: strlen ignored |
| 29 | // CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free |
| 30 | // CHECK-IGNORE: strlen ignored |