ramosian-glider / sanitizers

0 stars 0 forks source link

ASan doesn't always set DYLD_INSERT_LIBRARIES correctly on OSX #160

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 159

Example 1:

$ cat t.c
#include <unistd.h>
int main() {
  execl("/bin/bash", "/bin/bash", NULL);
}
$ bin/clang -fsanitize=address t.c -o t -g && ./t
dyld: Symbol not found: ___asan_mapping_offset
  Referenced from: /Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
  Expected in: flat namespace
 in /Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
Trace/BPT trap: 5

- i.e. we're still trying to preload the runtime library after exec().

Example 2:

$ cat f.c 
void foo() {}
$ bin/clang f.c -dynamiclib -o f.dylib
==13074== Parsed ASAN_OPTIONS: verbosity=1
==13074== exec()-ing the program with
==13074== DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
==13074== to enable ASan wrappers.
==13074== Set ASAN_OPTIONS=allow_reexec=0 to disable this.
==13074== Parsed ASAN_OPTIONS: verbosity=1
==13074== exec()-ing the program with
==13074== DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
==13074== to enable ASan wrappers.
==13074== Set ASAN_OPTIONS=allow_reexec=0 to disable this.
==13074== Parsed ASAN_OPTIONS: verbosity=1
==13074== exec()-ing the program with
==13074== DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
==13074== to enable ASan wrappers.
==13074== Set ASAN_OPTIONS=allow_reexec=0 to disable this.
==13074== Parsed ASAN_OPTIONS: verbosity=1
==13074== exec()-ing the program with
==13074== DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
==13074== to enable ASan wrappers.
==13074== Set ASAN_OPTIONS=allow_reexec=0 to disable this.
==13074== Parsed ASAN_OPTIONS: verbosity=1
==13074== exec()-ing the program with
==13074== DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/llvm_cmake_build/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
==13074== to enable ASan wrappers.
==13074== Set ASAN_OPTIONS=allow_reexec=0 to disable this.
==13074== Parsed ASAN_OPTIONS: verbosity=1
==13074== exec()-ing the program with
...

- i.e. the application falls into an exec() loop.

Reported by ramosian.glider on 2013-02-13 13:55:22

ramosian-glider commented 9 years ago
Example 2 fixed in Clang r175059.

Reported by ramosian.glider on 2013-02-13 17:53:41

ramosian-glider commented 9 years ago
FTR, the missing invocation string for Example 2 is:
$ DYLD_INSERT_LIBRARIES=f.dylib ./t

Reported by ramosian.glider on 2013-02-15 16:02:52

ramosian-glider commented 9 years ago
Fixed in Clang r175276.

Reported by ramosian.glider on 2013-02-15 16:13:40

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:13:40