1 // In a non-forking sandbox, we can't spawn an external symbolizer, but dladdr()
2 // should still work and provide function names. No line numbers though.
3 // Second, `atos` symbolizer can't inspect a process that has an inaccessible
4 // task port, in which case we should again fallback to dladdr gracefully.
5
6 // RUN: %clangxx_asan -O0 %s -o %t
7 // RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny process-fork)' %t 2>&1 | FileCheck %s
8 // RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny mach-priv-task-port)' %t 2>&1 | FileCheck %s
9 // RUN: env ASAN_SYMBOLIZER_PATH="" not %run sandbox-exec -p '(version 1)(allow default)(deny mach-priv-task-port)' %t 2>&1 | FileCheck %s
10 // RUN: %clangxx_asan -O3 %s -o %t
11 // RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny process-fork)' %t 2>&1 | FileCheck %s
12 // RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny mach-priv-task-port)' %t 2>&1 | FileCheck %s
13 // RUN: env ASAN_SYMBOLIZER_PATH="" not %run sandbox-exec -p '(version 1)(allow default)(deny mach-priv-task-port)' %t 2>&1 | FileCheck %s
14
15 #include <stdlib.h>
main()16 int main() {
17 char *x = (char*)malloc(10 * sizeof(char));
18 free(x);
19 return x[5];
20 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
21 // CHECK: {{READ of size 1 at 0x.* thread T0}}
22 // CHECK: {{ #0 0x.* in main}}
23 // CHECK: {{freed by thread T0 here:}}
24 // CHECK: {{ #0 0x.* in wrap_free}}
25 // CHECK: {{ #1 0x.* in main}}
26 // CHECK: {{previously allocated by thread T0 here:}}
27 // CHECK: {{ #0 0x.* in wrap_malloc}}
28 // CHECK: {{ #1 0x.* in main}}
29 }
30