Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 1 | // Check that the `atos` symbolizer works. |
| 2 | |
| 3 | // RUN: %clangxx_asan -O0 %s -o %t |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 4 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) not %run %t 2>&1 | FileCheck %s |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 5 | |
| 6 | // Check that when having a DYLD_ROOT_PATH set, the symbolizer still works. |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 7 | // RUN: env DYLD_ROOT_PATH="/" ASAN_OPTIONS=$ASAN_OPTIONS:verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) \ |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 8 | // RUN: not %run %t 2>&1 | FileCheck %s |
| 9 | |
| 10 | #include <stdlib.h> |
| 11 | #include <string.h> |
| 12 | int main(int argc, char **argv) { |
| 13 | char *x = (char*)malloc(10 * sizeof(char)); |
| 14 | memset(x, 0, 10); |
| 15 | int res = x[argc]; |
| 16 | free(x); |
| 17 | free(x + argc - 1); // BOOM |
| 18 | // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T0 |
| 19 | // CHECK: Using atos at user-specified path: |
| 20 | // CHECK: #0 0x{{.*}} in {{.*}}free |
| 21 | // CHECK: #1 0x{{.*}} in main {{.*}}atos-symbolizer.cc:[[@LINE-4]] |
| 22 | // CHECK: freed by thread T0 here: |
| 23 | // CHECK: #0 0x{{.*}} in {{.*}}free |
| 24 | // CHECK: #1 0x{{.*}} in main {{.*}}atos-symbolizer.cc:[[@LINE-8]] |
| 25 | // CHECK: allocated by thread T0 here: |
| 26 | // CHECK: atos-symbolizer.cc:[[@LINE-13]] |
| 27 | return res; |
| 28 | } |