[PATCH] D14336: [tsan] Fix the memcpy interceptor to be memmove compatible on OS X

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 08:40:40 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: kcc, samsonov, glider, dvyukov.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp, jasonk.

On OS X, memcpy and memmove are actually aliases of the same implementation, which means the interceptor of memcpy is also invoked when memmove is called.  The current implementation of the interceptor uses `internal_memcpy` to perform the actual memory operation, which can produce an incorrect result when memmove semantics are expected.  Let's call `REAL(memcpy)` instead.

http://reviews.llvm.org/D14336

Files:
  lib/tsan/rtl/tsan_interceptors.cc

Index: lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- lib/tsan/rtl/tsan_interceptors.cc
+++ lib/tsan/rtl/tsan_interceptors.cc
@@ -630,7 +630,7 @@
     MemoryAccessRange(thr, pc, (uptr)dst, size, true);
     MemoryAccessRange(thr, pc, (uptr)src, size, false);
   }
-  return internal_memcpy(dst, src, size);
+  return REAL(memcpy)(dst, src, size);
 }
 
 TSAN_INTERCEPTOR(void*, memmove, void *dst, void *src, uptr n) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14336.39210.patch
Type: text/x-patch
Size: 477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/a95820f1/attachment.bin>


More information about the llvm-commits mailing list