[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
This commit is contained in:
Kuba Brecka 2015-11-05 14:03:26 +00:00
parent 3d8536240a
commit 245bcf9eb9
1 changed files with 4 additions and 1 deletions

View File

@ -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) {