tsan in some cases (e.g. after fork from multithreaded program, which arguably is problematic) increments ignore_interceptors and in that case runs just the intercepted functions and not their wrappers.
For realpath the interceptor handles the resolved_path == nullptr case though and so when ignore_interceptors is non-zero, realpath (".", nullptr) will fail instead of succeeding.
This patch uses instead the COMMON_INTERCEPT_FUNCTION_GLIBC_VER_MIN macro to use realpath@@GLIBC_2.3 whenever possible (if not, then it is likely a glibc architecture
with more recent oldest symbol version than 2.3, for which any realpath in glibc will DTRT, or unsupported glibc older than 2.3), which never supported NULL as second argument.
Details
- Reviewers
dvyukov vitalybuka - Commits
- rGfaef0d042f52: Problem with realpath interceptor
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hi Jakub,
I don't remember if you have commit access or not. Do you want me to land this?
git commit --amend --author='name <email>' can be used for proper attribution in the future.
I used arc. I assumed it will do the right thing. It even asked about landing a patch by a different author.
Also I don't even see the email provided anywhere...
arc patch D107819 does the right thing if the Differential was uploaded via arc diff 'HEAD^'.
It seems it isn't, so the author name/email are not tracked.
Also I don't even see the email provided anywhere...
I assume that you know Jakub's email... otherwise you may ask for the information:)
I had to revert the patch because it breaks interceptor on some environments. I'll investigate the issue.
If TSAN issue is important to you, probably moving WRAP(malloc) workaround before COMMON_INTERCEPTOR_ENTER will fix it. I will accept the patch if are willing to try.
Could you also try to build some regression test for the TSAN issue?
What kind of problems are you talking about? Is it that some non-glibc system wants also the NULL resolved_path handling and doesn't have it in the libc?
To be precise, the patch would work fine if only the INIT_REALPATH macro is changed to the COMMON_INTERCEPT_FUNCTION_GLIBC_VER_MIN macro, but no reordering will help,
the problem is that tsan disables the wrappers altogether at some points and then it only calls the original function. And it is crucial that the original function is the right one.
It's GLIBC, it has all functions, but COMMON_INTERCEPT_FUNCTION_GLIBC_VER_MIN fallbacks to the old one. Patch works without fallback, but it will break non-glibc cases.
E.g. it will work COMMON_INTERCEPT_FUNCTION_VER which does not fallback