Index: lib/asan/asan_mac.cc =================================================================== --- lib/asan/asan_mac.cc +++ lib/asan/asan_mac.cc @@ -67,6 +67,7 @@ void __asan_init(); static const char kDyldInsertLibraries[] = "DYLD_INSERT_LIBRARIES"; +static const char kDylibSuffix[] = ".dylib"; LowLevelAllocator allocator_for_env; // Change the value of the env var |name|, leaking the original value. @@ -114,6 +115,15 @@ uptr fname_len = internal_strlen(info.dli_fname); const char *dylib_name = StripModuleName(info.dli_fname); uptr dylib_name_len = internal_strlen(dylib_name); + + // "Noinst" unit tests link the runtime statically. We can't re-exec there, + // because we have no dylib to insert. Wrappers don't work there (that's + // expected). + uptr suffix_len = internal_strlen(kDylibSuffix); + if (dylib_name_len < suffix_len || + internal_strcmp(dylib_name + dylib_name_len - suffix_len, kDylibSuffix)) + return; + if (!dyld_insert_libraries || !REAL(strstr)(dyld_insert_libraries, dylib_name)) { // DYLD_INSERT_LIBRARIES is not set or does not contain the runtime