This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Fix memmove/memcpy overlap detection on windows
ClosedPublic

Authored by etienneb on Jul 20 2016, 10:12 PM.

Details

Summary

The memcpy and memmove functions are the same on windows.
The overlap detection logic is incorrect.

printf-1 test:

stdin>:2:114: note: possible intended match here
==877412==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x0000002bf2a8,0x0000002bf2ad) and [0x0000002bf2a9, 0x0000002bf2ae) overlap
```                                                                                                                 ^

Diff Detail

Event Timeline

etienneb updated this revision to Diff 64819.Jul 20 2016, 10:12 PM
etienneb retitled this revision from to [compiler-rt] Fix memmove/memcpy overlap detection on windows.
etienneb updated this object.
etienneb added a reviewer: rnk.
etienneb updated this object.Jul 20 2016, 10:25 PM
rnk added inline comments.Jul 21 2016, 6:51 AM
lib/asan/asan_interceptors.cc
433

Should we go back, intercept memmove instead of memcpy, and then initialize REAL(memset) to REAL(memmove) so that we don't crash when calling it?

Suppose the user calls memcpy or memmove on free memory. The stack trace can either contain asam_memcpy or asan_memmove. Which do you think is better?

etienneb updated this revision to Diff 64905.Jul 21 2016, 8:45 AM

move to an different approach

etienneb marked an inline comment as done.Jul 21 2016, 8:46 AM

I tried the other approach, and it seems to work fine.

etienneb updated this revision to Diff 64909.Jul 21 2016, 9:05 AM

fix unittests

rnk accepted this revision.Jul 21 2016, 9:08 AM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.Jul 21 2016, 9:08 AM
etienneb closed this revision.Jul 21 2016, 9:14 AM