msvc: add asan support (disabled by default)

This commit is contained in:
Shawn Hoffman 2020-08-18 21:54:08 -07:00
parent 79a234eff7
commit 49b9deeb03
3 changed files with 20 additions and 1 deletions

View File

@ -49,6 +49,17 @@ public:
m_post_unprotect_time; m_post_unprotect_time;
}; };
#ifdef _MSC_VER
#define ASAN_DISABLE __declspec(no_sanitize_address)
#else
#define ASAN_DISABLE
#endif
static void ASAN_DISABLE perform_invalid_access(void* data)
{
*(volatile int*)data = 5;
}
TEST(PageFault, PageFault) TEST(PageFault, PageFault)
{ {
EMM::InstallExceptionHandler(); EMM::InstallExceptionHandler();
@ -61,7 +72,7 @@ TEST(PageFault, PageFault)
pfjit.m_data = data; pfjit.m_data = data;
auto start = std::chrono::high_resolution_clock::now(); auto start = std::chrono::high_resolution_clock::now();
*(volatile int*)data = 5; perform_invalid_access(data);
auto end = std::chrono::high_resolution_clock::now(); auto end = std::chrono::high_resolution_clock::now();
#define AS_NS(diff) \ #define AS_NS(diff) \

View File

@ -133,6 +133,9 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
</ClCompile> </ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug' And '$(EnableASAN)'=='true'">
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
</ClCompile>
<!--ClCompile Release--> <!--ClCompile Release-->
<ClCompile Condition="'$(Configuration)'=='Release'"> <ClCompile Condition="'$(Configuration)'=='Release'">
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>

View File

@ -4,6 +4,11 @@
<PlatformToolset>v142</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture> <PreferredToolArchitecture>x64</PreferredToolArchitecture>
<!-- To use ASAN, just uncomment this. For simplicity, you should run VS/windbg/etc
(including the built executables themselves) after using vcvarsall or similar to setup
environment, as ASAN needs access to libs and executables in the toolchain paths.
-->
<!--<EnableASAN>true</EnableASAN>-->
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>