Skip to content

[ASan][ADT] Don't scribble with ASan #79066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, I'd reword the second sentence to say Disable scribbling under ASan to... since ASan isn't disabling it, we're disabling it under ASan

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the text to be more precise. Thx!

// 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