Skip to content

Commit

Permalink
common: also do pedantic shutdown when running Clang sanitizers
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 8, 2024
1 parent b8f9df8 commit 9fe0d38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/common/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,21 @@ int CountTrailingZeroes(unsigned long long x);
// Work around lack of constexpr
#define CONSTEXPR constexpr

#ifdef __SANITIZE_ADDRESS__ // Detects GCC asan
#if defined(__SANITIZE_ADDRESS__) // Detects GCC and MSVC AddressSanitizer
# define USING_ADDRESS_SANITIZER
# define USING_SANITIZER
#elif defined(__SANITIZE_THREAD__) // Detects GCC ThreadSanitizer
# define USING_SANITIZER
#elif defined(__has_feature)
# if __has_feature(address_sanitizer) // Detects Clang asan
# if __has_feature(address_sanitizer) // Detects Clang AddressSanitizer
# define USING_ADDRESS_SANITIZER
# define USING_SANITIZER
# elif __has_feature(leak_sanitizer) // Detects Clang LeakSanitizer
# define USING_SANITIZER
# elif __has_feature(memory_sanitizer) // Detects Clang MemorySanitizer
# define USING_SANITIZER
# elif __has_feature(thread_sanitizer) // Detects Clang ThreadSanitizer
# define USING_SANITIZER
# endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/common/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Sys {
// This option can be turned on when debugging memory management
#ifdef BUILD_ENGINE
Cvar::Cvar<bool> pedanticShutdown("common.pedanticShutdown", "run useless shutdown procedures before exit", Cvar::NONE,
#ifdef __SANITIZE_ADDRESS__
#ifdef USING_SANITIZER
true);
#else
false);
Expand Down

0 comments on commit 9fe0d38

Please sign in to comment.