diff options
author | Tacet <advenam.tacet@trailofbits.com> | 2024-01-23 19:12:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 19:12:57 +0100 |
commit | 51a11f1c44b7bd7655687471d8c8912afb637efc (patch) | |
tree | 8612cfc1cf540457573d9ff58e7448d05fb8d591 | |
parent | 7fe951ad8af24d9b7072cbad58d22f2e6cb5da7e (diff) | |
download | llvm-51a11f1c44b7bd7655687471d8c8912afb637efc.zip llvm-51a11f1c44b7bd7655687471d8c8912afb637efc.tar.gz llvm-51a11f1c44b7bd7655687471d8c8912afb637efc.tar.bz2 |
[ASan][ADT] Don't scribble with ASan (#79066)
With this commit, scribbling under AddressSanitizer (ASan) is disabled to prevent overwriting poisoned objects (e.g., annotated short strings).
Needed by https://github.com/llvm/llvm-project/pull/79049
-rw-r--r-- | llvm/include/llvm/ADT/FunctionExtras.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h index 4cf1de4..c0bc30c 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h @@ -35,6 +35,7 @@ #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/STLForwardCompat.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MemAlloc.h" #include "llvm/Support/type_traits.h" #include <cstring> @@ -317,8 +318,10 @@ protected: // Clear the old callback and inline flag to get back to as-if-null. RHS.CallbackAndInlineFlag = {}; -#ifndef NDEBUG - // In debug builds, we also scribble across the rest of the storage. +#if !defined(NDEBUG) && !LLVM_ADDRESS_SANITIZER_BUILD + // In debug builds without ASan, we also scribble across the rest of the + // storage. Scribbling under AddressSanitizer (ASan) is disabled to prevent + // overwriting poisoned objects (e.g., annotated short strings). memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize); #endif } |