Error: memcpy-param-overlap
Address Sanitizer Error: memcpy-param-overlap
The CRT function memcpy doesn't support overlapping memory. The CRT provides an alternative to memcpy that does support overlapping memory: memmove.
A common error is to treat memmove as being semantically equivalent to memcpy.
Example
// example1.cpp
// memcpy-param-overlap error
#include <string.h>
__declspec(noinline) void bad_function() {
char buffer[] = "hello";
memcpy(buffer, buffer + 1, 5); // BOOM!
}
int main(int argc, char **argv) {
bad_function();
return 0;
}
To build and test this example, run these commands in a Visual Studio 2019 version 16.9 or later developer command prompt:
cl example1.cpp /fsanitize=address /Zi
devenv /debugexe example1.exe
Resulting error
See also
AddressSanitizer overview
AddressSanitizer known issues
AddressSanitizer build and language reference
AddressSanitizer runtime reference
AddressSanitizer shadow bytes
AddressSanitizer cloud or distributed testing
AddressSanitizer debugger integration
AddressSanitizer error examples
Maklum balas
Kirim dan lihat maklum balas untuk