The ASAN interposer for dlopen cannot accurately interpose dlopen because when it itself calls dlopen the dynamic loader considers ASAN to be the caller and the scope resolution for loading the library starts there. Instead what you want is for ASAN to be able to call dlopen but with the search scope of the library it is interposing, which may not even be known. Either way, we need some new kind of API here. The following example shows the situation: #include <dlfcn.h> #include <iostream> int main() { void *handle = dlopen("libb.so", RTLD_NOW); if (handle == NULL) { std::cout << "Failed to load libb.so" << std::endl; } } #mkdir lib #g++ --sanitize=address -Wl,-rpath='$ORIGIN/lib' -Wl,--enable-new-dtags -ldl -o main main.cpp #cd lib; Create libb.so: int foo() { return 1; } g++ -fPIC -shared b.C -o libb.so Actual results: strace ./main 2>&1 | grep libb.so open("/opt/rh/devtoolset-6/root/usr/lib/../lib64/tls/libb.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) : <snipped> : open("/usr/lib64/libb.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) write(1, "Failed to load libb.so\n", 23Failed to load libb.so Expected results: strace ./main 2>&1 | grep libb.so open("/opt/rh/devtoolset-6/root/usr/lib64/tls/libb.so", O_RDONLY) = -1 ENOENT (No such file or directory) open("/root/cc/lib/libb.so", O_RDONLY) = 3
*** Bug 28008 has been marked as a duplicate of this bug. ***