[compiler-rt] r359325 - [NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 10:49:49 PDT 2019
I added the the following comment to the chromium bug tracker. I apologize for all the extra work. :(
My best guess agrees with comment #2 above: before we were never doing `&func`, but now we do (in ASAN_INTERCEPT_FUNC).
As a temporary workaround, I think using INTERCEPT_FUNCTION should work instead of ASAN_INTERCEPT_FUNC.
Similar to here: https://github.com/llvm/llvm-project/commit/93c05f097a969666d48d67b8a658d5bc7e164478 <https://github.com/llvm/llvm-project/commit/93c05f097a969666d48d67b8a658d5bc7e164478>
(Thanks to Reid for cleaning up the fixme!)
However, similar to above I *think* that the change could have uncovered a small discrepancy: We are creating a `_except_handler4_common` interceptor, but there is no `_except_handler4_common` original function.
I think it is because the following two #if's predicate on different things (ASAN_DYNAMIC vs. ! _WIN64):
```
#if ASAN_DYNAMIC
// This handler is named differently in -MT and -MD CRTs.
#define _except_handler4 _except_handler4_common
#endif
INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
CHECK(REAL(_except_handler4));
__asan_handle_no_return();
return REAL(_except_handler4)(a, b, c, d);
}
#endif
...
__tsan::InitializePlatformInterceptors():
#ifdef _WIN64
ASAN_INTERCEPT_FUNC(__C_specific_handler);
#else
ASAN_INTERCEPT_FUNC(_except_handler3);
ASAN_INTERCEPT_FUNC(_except_handler4);
#endif
```
> On Apr 30, 2019, at 7:51 AM, Hans Wennborg <hans at chromium.org> wrote:
>
> The 32-bit windows dynamic asan runtime build is still broken, see https://bugs.chromium.org/p/chromium/issues/detail?id=957971 <https://bugs.chromium.org/p/chromium/issues/detail?id=957971>
> On Fri, Apr 26, 2019 at 7:27 PM Julian Lettner via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: yln
> Date: Fri Apr 26 10:29:22 2019
> New Revision: 359325
>
> URL: http://llvm.org/viewvc/llvm-project?rev=359325&view=rev <http://llvm.org/viewvc/llvm-project?rev=359325&view=rev>
> Log:
> [NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void
>
> This temporary change tells us about all the places where the return
> value of the INTERCEPT_FUNCTION macro is actually used. In the next
> patch I will cleanup the macro and remove GetRealFuncAddress.
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D61145 <https://reviews.llvm.org/D61145>
>
> Modified:
> compiler-rt/trunk/lib/asan/asan_interceptors.h
> compiler-rt/trunk/lib/interception/interception_linux.h
> compiler-rt/trunk/lib/msan/msan_interceptors.cc
>
> Modified: compiler-rt/trunk/lib/asan/asan_interceptors.h
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=359325&r1=359324&r2=359325&view=diff <http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=359325&r1=359324&r2=359325&view=diff>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_interceptors.h Fri Apr 26 10:29:22 2019
> @@ -122,12 +122,16 @@ DECLARE_REAL(char*, strstr, const char *
> #if !SANITIZER_MAC
> #define ASAN_INTERCEPT_FUNC(name) \
> do { \
> - if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \
> + INTERCEPT_FUNCTION(name); \
> + bool same = (& (name) == & WRAP(name)); \
> + if ((!same || !REAL(name))) \
> VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \
> } while (0)
> #define ASAN_INTERCEPT_FUNC_VER(name, ver) \
> do { \
> - if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \
> + INTERCEPT_FUNCTION_VER(name, ver); \
> + name##_type ptr = (::__interception::real_##name); \
> + if ((!ptr || !REAL(name))) \
> VReport( \
> 1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \
> } while (0)
>
> Modified: compiler-rt/trunk/lib/interception/interception_linux.h
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.h?rev=359325&r1=359324&r2=359325&view=diff <http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_linux.h?rev=359325&r1=359324&r2=359325&view=diff>
> ==============================================================================
> --- compiler-rt/trunk/lib/interception/interception_linux.h (original)
> +++ compiler-rt/trunk/lib/interception/interception_linux.h Fri Apr 26 10:29:22 2019
> @@ -30,16 +30,18 @@ void *GetFuncAddrVer(const char *name, c
> } // namespace __interception
>
> #define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \
> - ::__interception::GetRealFunctionAddress( \
> + do { ::__interception::GetRealFunctionAddress( \
> #func, (::__interception::uptr *)&__interception::PTR_TO_REAL(func), \
> (::__interception::uptr) & (func), \
> - (::__interception::uptr) & WRAP(func))
> + (::__interception::uptr) & WRAP(func)); \
> + } while (0) // TODO(yln): temporarily make macro void.
>
> // Android, Solaris and OpenBSD do not have dlvsym
> #if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
> #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
> - (::__interception::real_##func = (func##_type)( \
> - unsigned long)::__interception::GetFuncAddrVer(#func, symver))
> + do { (::__interception::real_##func = (func##_type)( \
> + unsigned long)::__interception::GetFuncAddrVer(#func, symver)); \
> + } while (0)
> #else
> #define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
> INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
>
> Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=359325&r1=359324&r2=359325&view=diff <http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=359325&r1=359324&r2=359325&view=diff>
> ==============================================================================
> --- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
> +++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Fri Apr 26 10:29:22 2019
> @@ -1243,13 +1243,17 @@ int OnExit() {
>
> #define MSAN_INTERCEPT_FUNC(name) \
> do { \
> - if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \
> + INTERCEPT_FUNCTION(name); \
> + bool same = (& (name) == & WRAP(name)); \
> + if ((!same || !REAL(name))) \
> VReport(1, "MemorySanitizer: failed to intercept '" #name "'\n"); \
> } while (0)
>
> #define MSAN_INTERCEPT_FUNC_VER(name, ver) \
> do { \
> - if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \
> + INTERCEPT_FUNCTION_VER(name, ver); \
> + name##_type ptr = (::__interception::real_##name); \
> + if ((!ptr || !REAL(name))) \
> VReport( \
> 1, "MemorySanitizer: failed to intercept '" #name "@@" #ver "'\n"); \
> } while (0)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190430/a055719b/attachment.html>
More information about the llvm-commits
mailing list