@@ -458,6 +458,17 @@ class BaseReport {
458458 access_size(access_size),
459459 untagged_addr(UntagAddr(tagged_addr)),
460460 ptr_tag(GetTagFromPointer(tagged_addr)) {
461+ if (MemIsShadow (untagged_addr))
462+ return ;
463+
464+ HwasanChunkView chunk = FindHeapChunkByAddress (untagged_addr);
465+ heap.begin = chunk.Beg ();
466+ if (heap.begin ) {
467+ heap.size = chunk.ActualSize ();
468+ heap.from_small_heap = chunk.FromSmallHeap ();
469+ heap.is_allocated = chunk.IsAllocated ();
470+ }
471+
461472 hwasanThreadList ().VisitAllLiveThreads ([&](Thread *t) {
462473 if (stack_allocations_count < ARRAY_SIZE (stack_allocations) &&
463474 t->AddrIsInStack (untagged_addr)) {
@@ -475,8 +486,16 @@ class BaseReport {
475486 uptr access_size = 0 ;
476487 uptr untagged_addr = 0 ;
477488 tag_t ptr_tag = 0 ;
489+
478490 uptr stack_allocations_count = 0 ;
479491 SavedStackAllocations stack_allocations[16 ];
492+
493+ struct {
494+ uptr begin = 0 ;
495+ uptr size = 0 ;
496+ bool from_small_heap = false ;
497+ bool is_allocated = false ;
498+ } heap;
480499};
481500
482501void BaseReport::PrintAddressDescription () const {
@@ -490,17 +509,14 @@ void BaseReport::PrintAddressDescription() const {
490509 }
491510
492511 // Print some very basic information about the address, if it's a heap.
493- HwasanChunkView chunk = FindHeapChunkByAddress (untagged_addr);
494- if (uptr beg = chunk.Beg ()) {
495- uptr size = chunk.ActualSize ();
496- Printf (" %s[%p,%p) is a %s %s heap chunk; "
497- " size: %zd offset: %zd\n %s" ,
498- d.Location (),
499- beg, beg + size,
500- chunk.FromSmallHeap () ? " small" : " large" ,
501- chunk.IsAllocated () ? " allocated" : " unallocated" ,
502- size, untagged_addr - beg,
503- d.Default ());
512+ if (heap.begin ) {
513+ Printf (
514+ " %s[%p,%p) is a %s %s heap chunk; "
515+ " size: %zd offset: %zd\n %s" ,
516+ d.Location (), heap.begin , heap.begin + heap.size ,
517+ heap.from_small_heap ? " small" : " large" ,
518+ heap.is_allocated ? " allocated" : " unallocated" , heap.size ,
519+ untagged_addr - heap.begin , d.Default ());
504520 }
505521
506522 // Check stack first. If the address is on the stack of a live thread, we
0 commit comments