diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2015-11-05 14:03:26 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2015-11-05 14:03:26 +0000 |
commit | 245bcf9eb949c547dc3f0bdcb090152db2b6120b (patch) | |
tree | a8d93bcb24916cc221c570494ddf25a76e54f6b2 | |
parent | 3d8536240acb2553b34741f6571380f61edc9bba (diff) | |
download | bcm5719-llvm-245bcf9eb949c547dc3f0bdcb090152db2b6120b.tar.gz bcm5719-llvm-245bcf9eb949c547dc3f0bdcb090152db2b6120b.zip |
[tsan] Fix the memcpy interceptor to be memmove compatible on OS X
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 `internal_memmove` instead.
Differential Revision: http://reviews.llvm.org/D14336
llvm-svn: 252162
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_interceptors.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc index 7d2194d8368..8308afb7c24 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc @@ -626,7 +626,10 @@ TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) { MemoryAccessRange(thr, pc, (uptr)dst, size, true); MemoryAccessRange(thr, pc, (uptr)src, size, false); } - return internal_memcpy(dst, src, size); + // On OS X, calling internal_memcpy here will cause memory corruptions, + // because memcpy and memmove are actually aliases of the same implementation. + // We need to use internal_memmove here. + return internal_memmove(dst, src, size); } TSAN_INTERCEPTOR(void*, memmove, void *dst, void *src, uptr n) { |