Open
Description
I hook socket relevant c function in my project, like getaddrinfo,connect,socket and so on. When I open address sanitizer for debug I found some error like this:
It seems that both address sanitizer and fishhook hooked getaddrinfo() , and result in a conflict.
The following WWDC video said sanitizer hook standard c library.
reference: https://developer.apple.com/videos/play/wwdc2015/413/
Activity
dlow-yahoo-inc commentedon Sep 7, 2018
I ran into the same problem. After some poking around, I think I understand what's causing the infinite recursion:
When building an app with "Thread Sanitizer" or "Address Sanitizer", the compiler generates a special DLL named
libclang_rt.tsan_iossim_dynamic.dylib
(tsan
-> Thread Sanitizer) orlibclang_rt.asan_iossim_dynamic.dylib
(asan
-> Address Sanitizer). These libraries contain wrapper functions corresponding to system APIs (eg. wrap_getaddrinfo() for getaddrinfo()).These special DLLs are "interposed" by the linker on top of the system libraries before the app's symbols are resolved. The pseudocode for wrap_getaddrinfo() looks like:
When Fishhook does it's rebinding, it does a massive search & replace of all references of getaddrinfo() to MAM_getaddrinfo(). Including the one in the specially generated DLL. Hence, leading to the infinite recursion.
Whatever the solution, it will involve breaking this cycle.
dlow-yahoo-inc commentedon Sep 7, 2018
A dirty hack that seems to work is:
A better fix would be to better identify these special compiler generated DLLs instead of hardcoding the file names.
tirodkar commentedon Oct 23, 2020
@grp Is there any plan for adding any of the suggested fixes? It would be incredibly advantageous for users trying to debug with sanitizers and fishhook.
tirodkar commentedon Nov 10, 2020
This causes a compilation issue with
basename
. Do you have a branch?LeoNatan commentedon Feb 9, 2021
@tirodkar For me, the following change worked:
Add
at the top section, then the following changes:
(There was a bug in @dlow-yahoo-inc ‘s code above, but easy to fix.)