Index: lib/asan/asan_mac.cc =================================================================== --- lib/asan/asan_mac.cc +++ lib/asan/asan_mac.cc @@ -114,7 +114,7 @@ internal_strlen(dyld_insert_libraries) : 0; uptr fname_len = internal_strlen(info.dli_fname); if (!dyld_insert_libraries || - !REAL(strstr)(dyld_insert_libraries, info.dli_fname)) { + !REAL(strstr)(dyld_insert_libraries, StripModuleName(info.dli_fname))) { // DYLD_INSERT_LIBRARIES is not set or does not contain the runtime // library. char program_name[1024]; Index: test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc =================================================================== --- test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc +++ test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc @@ -0,0 +1,15 @@ +// When DYLD-inserting the ASan dylib from a different location than the +// original, make sure we don't try to reexec. + +// RUN: mkdir -p %T/dyld_insert_libraries_reexec +// RUN: cp `%clang_asan %s -fsanitize=address -### 2>&1 | grep "libclang_rt.asan_osx_dynamic.dylib" | sed -e 's/.*"\(.*libclang_rt.asan_osx_dynamic.dylib\)".*/\1/'` %T/dyld_insert_libraries_reexec/libclang_rt.asan_osx_dynamic.dylib +// RUN: %clangxx_asan %s -o %T/dyld_insert_libraries_reexec/dyld_insert_libraries_reexec.tmp +// RUN: DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib %run %T/dyld_insert_libraries_reexec/dyld_insert_libraries_reexec.tmp 2>&1 | FileCheck %s + +#include + +int main() { + printf("Passed\n"); + return 0; +} +// CHECK: Passed