In glibc 2.36 the behaviour of RTLD_NEXT had been changed after [1]
patch:
#define _GNU_SOURCE #include <dlfcn.h> #include <stdio.h> int main() { void *p = dlsym(RTLD_NEXT, "__pthread_mutex_lock"); printf("__pthread_mutex_lock: %p (via RTLD_NEXT)\n", p); return 0; }
Results:
libc 2.35: __pthread_mutex_lock: 0x7ffff7e27f70 (via RTLD_NEXT) libc 2.36: __pthread_mutex_lock: (nil) (via RTLD_NEXT)
[1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=efa7936e4c91b1c260d03614bb26858fbb8a0204
The problem is that now RTLD_NEXT does not return symbols that had been
marked as internal (like pthread_mutex_lock/pthread_mutex_unlock).
And so if you will use it in your program and try to build it with ASan
it will lead to NULL dereference.
And this is indeed what happened in case of ClickHouse. And even though
the fix is simple [2], looks like it is still worth to fix it in llvm
too (since it can take sometime to find this).