[PATCH] [Tsan] Do not sanitize memset() and other functions during initialization

Phabricator reviews at reviews.llvm.org
Fri Mar 27 07:15:09 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8544

Files:
  compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc

Index: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
@@ -156,6 +156,9 @@
 const int SIG_SETMASK = 2;
 #endif
 
+#define COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED \
+  (!cur_thread()->is_inited)
+
 namespace std {
 struct nothrow_t {};
 }  // namespace std
@@ -663,14 +666,17 @@
 }
 
 TSAN_INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {
-  SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);
-  MemoryAccessRange(thr, pc, (uptr)dst, size, true);
+  // On FreeBSD we get here from libthr internals on thread initialization.
+  if (!COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) {
+    SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);
+    MemoryAccessRange(thr, pc, (uptr)dst, size, true);
+  }
   return internal_memset(dst, v, size);
 }
 
 TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {
   // On FreeBSD we get here from libthr internals on thread initialization.
-  if (cur_thread()->is_inited) {
+  if (!COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) {
     SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);
     MemoryAccessRange(thr, pc, (uptr)dst, size, true);
     MemoryAccessRange(thr, pc, (uptr)src, size, false);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8544.22798.patch
Type: text/x-patch
Size: 1331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150327/45057a0a/attachment.bin>


More information about the llvm-commits mailing list