From dd691757ff8bf47513bbe5f5fbdb17ae730388d0 Mon Sep 17 00:00:00 2001 From: mickael gilabert Date: Mon, 12 Aug 2024 16:54:18 -0400 Subject: [PATCH] Disable ASAN global variable check in vctoolchain when using clang compiler. This can lead to false / positive with ASan mixing types of different size in its shadow space (for instance, null character being shared for char and wchar_t but having different sizes (1 for char and 2 for wchar_t)) [REVIEW] [at]ben.woodhouse #rnx #rb ben.woodhouse [CL 35467128 by mickael gilabert in ue5-main branch] --- .../UnrealBuildTool/Platform/Windows/VCToolChain.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs b/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs index ce1b84216db4..69f8712c8a57 100644 --- a/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs +++ b/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs @@ -614,6 +614,13 @@ namespace UnrealBuildTool // Works for clang too. Arguments.Add("/fsanitize=address"); + if (Target.WindowsPlatform.Compiler.IsClang()) + { + // Don't check global variables when address sanitizer is enabled. This can lead to false / positive with ASan mixing types of different size in its shadow space + // (for instance, null character being shared for char and wchar_t but having different sizes (1 for char and 2 for wchar_t)) + Arguments.Add("-mllvm -asan-globals=0"); + } + // Use the CRT allocator so that ASan is able to hook into it for better error // detection. AddDefinition(Arguments, "FORCE_ANSI_ALLOCATOR=1");