Skip to content

Commit 51a11f1

Browse files
author
Tacet
authored
[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 #79049
1 parent 7fe951a commit 51a11f1

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>
@@ -317,8 +318,10 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
317318
// Clear the old callback and inline flag to get back to as-if-null.
318319
RHS.CallbackAndInlineFlag = {};
319320

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

0 commit comments

Comments
 (0)