[llvm] 51a11f1 - [ASan][ADT] Don't scribble with ASan (#79066)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 10:13:02 PST 2024


Author: Tacet
Date: 2024-01-23T19:12:57+01:00
New Revision: 51a11f1c44b7bd7655687471d8c8912afb637efc

URL: https://github.com/llvm/llvm-project/commit/51a11f1c44b7bd7655687471d8c8912afb637efc
DIFF: https://github.com/llvm/llvm-project/commit/51a11f1c44b7bd7655687471d8c8912afb637efc.diff

LOG: [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

Added: 
    

Modified: 
    llvm/include/llvm/ADT/FunctionExtras.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 4cf1de488c7bde2..c0bc30c7450fe4b 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 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
     // 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
   }


        


More information about the llvm-commits mailing list