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 -framework Foundation |
| 3 | // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s |
| 4 | |
| 5 | // Check that suppressing the interceptor by name works. |
| 6 | // RUN: echo "interceptor_name:memmove" > %t.supp |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 7 | // 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] | 8 | |
| 9 | // Check that suppressing by interceptor name works even without the symbolizer |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 10 | // RUN: env ASAN_OPTIONS="$ASAN_OPTIONS:suppressions='%t.supp':symbolize=false" %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 11 | |
| 12 | // Check that suppressing all reports from a library works. |
| 13 | // RUN: echo "interceptor_via_lib:CoreFoundation" > %t.supp |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 14 | // 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] | 15 | |
| 16 | // Check that suppressing library works even without the symbolizer. |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 17 | // RUN: env ASAN_OPTIONS="$ASAN_OPTIONS:suppressions='%t.supp':symbolize=false" %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 18 | |
| 19 | #include <CoreFoundation/CoreFoundation.h> |
| 20 | |
| 21 | int main() { |
| 22 | char *a = (char *)malloc(6); |
| 23 | strcpy(a, "hello"); |
| 24 | CFStringRef str = |
| 25 | CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char *)a, 10, |
| 26 | kCFStringEncodingUTF8, FALSE); // BOOM |
| 27 | fprintf(stderr, "Ignored.\n"); |
| 28 | free(a); |
| 29 | } |
| 30 | |
| 31 | // CHECK-CRASH: AddressSanitizer: heap-buffer-overflow |
| 32 | // CHECK-CRASH-NOT: Ignored. |
| 33 | // CHECK-IGNORE-NOT: AddressSanitizer: heap-buffer-overflow |
| 34 | // CHECK-IGNORE: Ignored. |