32 lines · cpp
1// Check that when having a DYLD_ROOT_PATH set, the symbolizer still works.2// RUN: %clangxx_asan -O0 %s -o %t3// RUN: which atos | tr -d '\n' > %t.symbolizer_path4// RUN: %env_asan_opts=verbosity=2 DYLD_ROOT_PATH="/" ASAN_SYMBOLIZER_PATH=%{readfile:%t.symbolizer_path} \5// RUN: not %run %t 2>&1 | FileCheck %s6//7// Due to a bug in atos, this only works on x86_64.8// REQUIRES: asan-64-bits9 10// Path returned by `which atos` is invalid on iOS.11// UNSUPPORTED: ios12 13#include <stdlib.h>14#include <string.h>15int main(int argc, char **argv) {16 char *x = (char*)malloc(10 * sizeof(char));17 memset(x, 0, 10);18 int res = x[argc];19 free(x);20 free(x + argc - 1); // BOOM21 // CHECK: Using atos at user-specified path:22 // CHECK: AddressSanitizer: attempting double-free{{.*}}in thread T023 // CHECK: #0 0x{{.*}} in {{.*}}free24 // CHECK: #1 0x{{.*}} in main {{.*}}atos-symbolizer-dyld-root-path.cpp:[[@LINE-4]]25 // CHECK: freed by thread T0 here:26 // CHECK: #0 0x{{.*}} in {{.*}}free27 // CHECK: #1 0x{{.*}} in main {{.*}}atos-symbolizer-dyld-root-path.cpp:[[@LINE-8]]28 // CHECK: allocated by thread T0 here:29 // CHECK: atos-symbolizer-dyld-root-path.cpp:[[@LINE-13]]30 return res;31}32