This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Fix the memcpy interceptor to be memmove compatible on OS X
ClosedPublic

Authored by kubamracek on Nov 4 2015, 8:40 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek updated this revision to Diff 39210.Nov 4 2015, 8:40 AM
kubamracek retitled this revision from to [tsan] Fix the memcpy interceptor to be memmove compatible on OS X.
kubamracek updated this object.
kubamracek added reviewers: kcc, samsonov, glider, dvyukov.
dvyukov edited edge metadata.Nov 4 2015, 8:52 AM

I suspect there were reasons to call internal_memcpy. For example, if we intercept memcpy from dynamic loader when nothing is initialized yet, REAL(memcpy) is NULL.
We generally try to move in the opposite direction -- the less we call out from runtime, the less problems we have.
Use internal_memmove, it is already implemented.

kubamracek updated this revision to Diff 39334.Nov 5 2015, 2:46 AM
kubamracek edited edge metadata.

Updating patch to use internal_memmove and adding a comment.

dvyukov accepted this revision.Nov 5 2015, 2:56 AM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Nov 5 2015, 2:56 AM
This revision was automatically updated to reflect the committed changes.