Skip to content

Commit 0e41a6d

Browse files
Tacetarichardson
authored andcommitted
[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 llvm/llvm-project#79049
2 parents b5ef665 + 51a11f1 commit 0e41a6d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "llvm/ADT/PointerIntPair.h"
3636
#include "llvm/ADT/PointerUnion.h"
3737
#include "llvm/ADT/STLForwardCompat.h"
38+
#include "llvm/Support/Compiler.h"
3839
#include "llvm/Support/MemAlloc.h"
3940
#include "llvm/Support/type_traits.h"
4041
#include <cstring>
@@ -319,8 +320,10 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
319320
// Clear the old callback and inline flag to get back to as-if-null.
320321
RHS.CallbackAndInlineFlag = {};
321322

322-
#ifndef NDEBUG
323-
// In debug builds, we also scribble across the rest of the storage.
323+
#if !defined(NDEBUG) && !LLVM_ADDRESS_SANITIZER_BUILD
324+
// In debug builds without ASan, we also scribble across the rest of the
325+
// storage. Scribbling under AddressSanitizer (ASan) is disabled to prevent
326+
// overwriting poisoned objects (e.g., annotated short strings).
324327
memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
325328
#endif
326329
}

0 commit comments

Comments
 (0)