Skip to content

Commit

Permalink
[ASan][ADT] Don't scribble with ASan (#79066)
Browse files Browse the repository at this point in the history
With this commit, scribbling under AddressSanitizer (ASan) is disabled to prevent  overwriting poisoned objects (e.g., annotated short strings).
Needed by #79049
  • Loading branch information
Tacet authored Jan 23, 2024
1 parent 7fe951a commit 51a11f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions llvm/include/llvm/ADT/FunctionExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 51a11f1

Please sign in to comment.