Skip to content

Commit 4f46e9f

Browse files
author
Advenam Tacet
committed
Unpoison memory before reinterpret
This commit unpoisons memory before using memory as different types/before memset. Buildobts were failing and therefore short string annotations were turned off. Here: llvm#78627 This commit unpoisons memory before debug "scribble across the rest of the storage", as well as before reinterpret cast of an union.
1 parent 615b747 commit 4f46e9f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
319319

320320
#ifndef NDEBUG
321321
// In debug builds, we also scribble across the rest of the storage.
322+
#ifndef _LIBCPP_HAS_NO_ASAN
323+
__asan_unpoison_memory_region(RHS.getInlineStorage(), InlineStorageSize);
324+
#endif
322325
memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
323326
#endif
324327
}

llvm/include/llvm/Support/JSON.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ class Value {
482482
friend class Object;
483483

484484
template <typename T, typename... U> void create(U &&... V) {
485+
#ifndef _LIBCPP_HAS_NO_ASAN
486+
__asan_unpoison_memory_region(&Union, sizeof(T));
487+
#endif
485488
new (reinterpret_cast<T *>(&Union)) T(std::forward<U>(V)...);
486489
}
487490
template <typename T> T &as() const {

0 commit comments

Comments
 (0)