Skip to content

Commit

Permalink
[ASan][ADT] Don't scribble with ASan
Browse files Browse the repository at this point in the history
AddressSanitizer (ASAN) disables scribbling to prevent overwriting poisoned objects.
Needed by llvm#79049
  • Loading branch information
Advenam Tacet committed Jan 22, 2024
1 parent cc2c8ab commit 21c85d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/include/llvm/ADT/FunctionExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,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) && !(defined(ADDRESS_SANITIZER) || defined(__SANITIZE_ADDRESS__))
// In debug builds without ASan, we also scribble across the rest of the storage.
// AddressSanitizer (ASAN) disables scribbling to prevent overwriting poisoned objects
// (e.g., annotated short strings).
memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
#endif
}
Expand Down

0 comments on commit 21c85d9

Please sign in to comment.