I am trying to setup Asan Address Sanitizer for Visual Studio 2022. I am following this guide from MS: https://learn.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-170#ide-msbuild
I was able to (mostly, I think) follow the instructions.
But I get this warning when running my code with Asan.
==14676==WARNING: Failed to use and restart external symbolizer!
#0 0x7ff67ec8109f in main C:\Users\Vader\source\repos\AsanTest\AsanTest\main.cpp:5
#1 0x7ff67ec81f68 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
#2 0x7ff67ec81ebd in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
#3 0x7ff67ec81d7d in __scrt_common_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:330
#4 0x7ff67ec81fdd in mainCRTStartup D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:16
#5 0x7ffe54d07613 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017613)
#6 0x7ffe563226b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)
The instructions say to do 4 things:
1. Turn off edit and continue ✅
2. Turn off /RTC1 (runtime checks) ✅ Turned off RTC1 by right clicking on the field and deleting the value.
3. Turn off /INCREMENTAL (incremental linking) ✅
When I do the "Use AddressSanitizer from a developer command prompt" I do not get this warning.
The test code
#include <stdio.h>
int x[100];
int main() {
printf("Hello!\n");
x[100] = 5; // Boom!
return 0;
}
The problem has been asked before.
You can vote on issues and leave comments to bring developers attention.
The problem is related to the Visual Studio debugging environment. The same program running in visual studio will output a warning Failed to use and restart external symbolizer
,but not on cmd.
There is
PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86;%PATH%
ASAN_SYMBOLIZER_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86
in Project's properties-> Debugging->Environment. Remove the variable and the warning disappears.