I'm trying to use the address sanitizer to pinpoint a memory bug in another program, but I can't get it to work. It compiles but running the executable gives
AddressSanitizer: CHECK failed: sanitizer_common_interceptors_memintrinsics.inc:239 "((__interception::real_memcpy)) != (0)" (0x0, 0x0) (tid=4584)
<empty stack>
The code editor I'm using is VS code, the llvm version is 20.1.8, and the library version is 20.1.0. There is no usual "==" error message before what I've posted, this is the full output. Here are the test code and task.json I'm using:
#include <iostream>
int main() {
std::cout << "ASan test OK\n";
return 0;
}
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "llvm-mingw clang++",
"command": "C:\\llvm-mingw\\bin\\clang++.exe",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"-fsanitize=address",
"-Xlinker",
"--subsystem=console",
"-Xlinker",
"--entry=mainCRTStartup",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: C:\\llvm-mingw\\bin\\clang++.exe"
},
]
}
The only things I've found online say to put libclang_rt.asan_dynamic-x86_64.dll in the same folder as the executable and put C:\llvm-mingw\bin in my environment path variables under "edit system environment variables", both of which I've done.
I can't get it to work.
The error message comes from AddressSanitizer runtime attempting to (and failing) to interpose the libc
memcpy
routine.
It doesn't look like AddressSanitizer supports mingw
1, 2.
There is AddressSanitizer support in VisualStudio, but that looks like the only way to use it on Windows.