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_name:strlen" > %t.supp |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 6 | // RUN: env ASAN_OPTIONS="$ASAN_OPTIONS: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] | 7 | |
| 8 | // XFAIL: android |
| 9 | |
| 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <string.h> |
| 13 | |
| 14 | int main() { |
| 15 | char *a = (char *)malloc(6); |
| 16 | free(a); |
| 17 | size_t len = strlen(a); // BOOM |
| 18 | fprintf(stderr, "strlen ignored, len = %zu\n", len); |
| 19 | } |
| 20 | |
| 21 | // CHECK-CRASH: AddressSanitizer: heap-use-after-free |
| 22 | // CHECK-CRASH-NOT: strlen ignored |
| 23 | // CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free |
| 24 | // CHECK-IGNORE: strlen ignored |