[compiler-rt] dc810e8 - [NFC][hwasan] Collect heap related data early (#66682)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 18:41:05 PDT 2023
Author: Vitaly Buka
Date: 2023-09-18T18:41:00-07:00
New Revision: dc810e880f4ea5e551c635987e63198da472e11e
URL: https://github.com/llvm/llvm-project/commit/dc810e880f4ea5e551c635987e63198da472e11e
DIFF: https://github.com/llvm/llvm-project/commit/dc810e880f4ea5e551c635987e63198da472e11e.diff
LOG: [NFC][hwasan] Collect heap related data early (#66682)
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_report.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index e9d0bf27b0436e3..6272e7116846cb4 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -458,6 +458,17 @@ class BaseReport {
access_size(access_size),
untagged_addr(UntagAddr(tagged_addr)),
ptr_tag(GetTagFromPointer(tagged_addr)) {
+ if (MemIsShadow(untagged_addr))
+ return;
+
+ HwasanChunkView chunk = FindHeapChunkByAddress(untagged_addr);
+ heap.begin = chunk.Beg();
+ if (heap.begin) {
+ heap.size = chunk.ActualSize();
+ heap.from_small_heap = chunk.FromSmallHeap();
+ heap.is_allocated = chunk.IsAllocated();
+ }
+
hwasanThreadList().VisitAllLiveThreads([&](Thread *t) {
if (stack_allocations_count < ARRAY_SIZE(stack_allocations) &&
t->AddrIsInStack(untagged_addr)) {
@@ -475,8 +486,16 @@ class BaseReport {
uptr access_size = 0;
uptr untagged_addr = 0;
tag_t ptr_tag = 0;
+
uptr stack_allocations_count = 0;
SavedStackAllocations stack_allocations[16];
+
+ struct {
+ uptr begin = 0;
+ uptr size = 0;
+ bool from_small_heap = false;
+ bool is_allocated = false;
+ } heap;
};
void BaseReport::PrintAddressDescription() const {
@@ -490,17 +509,14 @@ void BaseReport::PrintAddressDescription() const {
}
// Print some very basic information about the address, if it's a heap.
- HwasanChunkView chunk = FindHeapChunkByAddress(untagged_addr);
- if (uptr beg = chunk.Beg()) {
- uptr size = chunk.ActualSize();
- Printf("%s[%p,%p) is a %s %s heap chunk; "
- "size: %zd offset: %zd\n%s",
- d.Location(),
- beg, beg + size,
- chunk.FromSmallHeap() ? "small" : "large",
- chunk.IsAllocated() ? "allocated" : "unallocated",
- size, untagged_addr - beg,
- d.Default());
+ if (heap.begin) {
+ Printf(
+ "%s[%p,%p) is a %s %s heap chunk; "
+ "size: %zd offset: %zd\n%s",
+ d.Location(), heap.begin, heap.begin + heap.size,
+ heap.from_small_heap ? "small" : "large",
+ heap.is_allocated ? "allocated" : "unallocated", heap.size,
+ untagged_addr - heap.begin, d.Default());
}
// Check stack first. If the address is on the stack of a live thread, we
More information about the llvm-commits
mailing list