[PATCH] [Tsan] Do not intercept non-FreeBSD functions on FreeBSD

Viktor Kutuzov vkutuzov at accesssoftek.com
Fri Oct 24 01:26:46 PDT 2014


================
Comment at: lib/tsan/rtl/tsan_interceptors.cc:108
@@ -107,1 +107,3 @@
 
+#define TSAN_INTERCEPT_MMAP64 SANITIZER_LINUX
+#define TSAN_INTERCEPT_MEMALIGN SANITIZER_LINUX
----------------
dvyukov wrote:
> What's the point in defining these TSAN_INTERCEPT_MMAP64 macros? Looks like an unnecessary level of indirection. They are used exactly once, and now I need to modify 3 places in stead of 2 when working with an interceptor.
> Please remove TSAN_INTERCEPT_MMAP64 macros and use the condition (e.g. SANITIZER_LINUX) directly. Looks like a net win to me.
> What's the point in defining these TSAN_INTERCEPT_MMAP64 macros? Looks like an unnecessary level of indirection. They are used exactly once, and now I need to modify 3 places in stead of 2 when working with an interceptor.

Well, the idea is to control the presence of a given interceptor in a single place. For example, if we want mmap64() to be defined on MAC, then we can do it with a single-line change:

  #define TSAN_INTERCEPT_MMAP64 SANITIZER_LINUX || SANITIZER_MAC

and it will affect both the presence of the interceptor's definition and its initialization in InitializeInterceptors() so no need to change them (even though the very macro is used only once indeed).

In contrast, surrounding interceptors and their initializations with #if/#endif means we need to change two lines and also take special care to make sure the conditions for the interceptor itself and its initialization do match.

> Please remove TSAN_INTERCEPT_MMAP64 macros and use the condition (e.g. SANITIZER_LINUX) directly. Looks like a net win to me.

Sounds like the previous version?

http://reviews.llvm.org/differential/diff/15120/

http://reviews.llvm.org/D5858






More information about the llvm-commits mailing list