-
Address Sanitizer 적용 빌드 (UE 5.3)개발/UnrealEngine 2024. 4. 9. 20:46728x90
Visual Studio 2019 (16.9) 부터 C/C++ 컴파일러는 Address Sanitizer 를 기본적으로 지원한다.
Address Sanitizer 는 힙 메모리 관련한 디버깅을 할때 도움을 주는 도구이다.
Address Sanitizer 의 자세한 내용은 MSVC 도움말을 참고하자.
UnrealEngine 에서도 해당 빌드를 실행할 수 있는데, Source 폴더의 XXX.Target.cs 파일을 수정해서 설정하면 된다.
// Copyright Epic Games, Inc. All Rights Reserved. using UnrealBuildTool; using System.Collections.Generic; public class MyEditorTarget : TargetRules { public MyEditorTarget(TargetInfo Target) : base(Target) { .... WindowsPlatform.bEnableAddressSanitizer = true; ... } }
위와 같이 셋팅하면 Address Sanitizer 가 적용된 빌드를 실행 할 수 있게 된다.
하지만 아쉽게도 그냥 되는 법이 없다. 플러그인 로딩 오류이다.
로그를 보면 다음과 같은 에러가 뜨는 것을 볼 수 있다.
{"Time":"2024-04-09T12:20:03.191Z","Category":"LogWindows","Verbosity":"Log","Message":" Missing import: clang_rt.asan_dynamic-x86_64.dll"}
clang_rt.asan_dynamic-x86_64.dll 를 로딩 할 수 없어서 문제가 생긴것이다. Visual Studio 설치에 C++ AddressSanitizer 가 적절히 선택되어 있다면 문제 없지만 선택되어 있지 않다면 설치해준다.
C++ AddressSanitizer 를 설치 해야 한다 그러면 다음 폴더로 열심히 찾아 들어가면 해당 파일이 있는 것을 확인 할 수 있다.
폴더 중간의 숫자는 버전이므로 다를 수 있음을 감안하자.
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64
해당 폴더를 환경설정의 Path 넣던지, Unreal Project 의 Binaries/Win64 폴더에 복사하던지 하자.
그러면 드디어 실행!
Reference
언리얼 엔진 프로젝트에서 클랭 새니타이저 사용하기
Android 및 Linux 빌드에서 클랭 새니타이저를 사용하여 문제를 빠르게 진단합니다.
dev.epicgames.com
https://learn.microsoft.com/ko-kr/cpp/sanitizers/asan?view=msvc-170
AddressSanitizer
Microsoft C/C++용 AddressSanitizer 기능에 대한 최상위 설명입니다.
learn.microsoft.com
MSVC Address Sanitizer - One DLL for all Runtime Configurations - C++ Team Blog
With Visual Studio 2022 version 17.7 Preview 3, we have refactored the MSVC Address Sanitizer (ASan) to depend on one runtime DLL regardless of the runtime configuration. This simplifies project onboarding and supports more scenarios, particularly for proj
devblogs.microsoft.com
Application crashes when using address sanitizer with MSVC
I am trying to use address sanitizer with MSVC. Visual Studio Installer says I have "Visual Studio Community 2019" version 16.9.0. I have the most basic C++ program: int main() { retu...
stackoverflow.com
728x90