[PATCH] [compiler-rt] Make MaybeReexec properly process DYLD_INSERT_LIBRARIES when using non-absolute paths

Kuba Brecka kuba.brecka at gmail.com
Fri Jan 23 22:48:35 PST 2015


MaybeReexec() in asan_mac.cc checks for presence of the ASan dylib in DYLD_INSERT_LIBRARIES, and if it is there, it will process this env. var. and remove the dylib from its value, so that spawned children don't have this variable set.

However, the current implementation only works when using a canonical absolute path to the dylib, it fails to remove the dylib for example when using @executable_path:

    $ cat a.c
    int main() {
        printf("Hello world.\n");
        system("ls");
    }
    $ ls
    a.c
    libclang_rt.asan_osx_dynamic.dylib
    $ clang -fsanitize=address a.c
    $ ./a.out
    a.c
    a.out
    libclang_rt.asan_osx_dynamic.dylib
    $ DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib ./a.out
    Hello world.
    dyld: could not load inserted library '@executable_path/libclang_rt.asan_osx_dynamic.dylib' because image not found
    $ 

(here it's `ls` that fails to launch, because it's @executable_path is different)

This patch changes the processing of DYLD_INSERT_LIBRARIES to comparing values only based on filenames (ignoring directories).

http://reviews.llvm.org/D7160

Files:
  lib/asan/asan_mac.cc
  lib/sanitizer_common/sanitizer_libc.cc
  lib/sanitizer_common/sanitizer_libc.h
  test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cc

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7160.18716.patch
Type: text/x-patch
Size: 8767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150124/331a9065/attachment.bin>


More information about the llvm-commits mailing list