From 98cc600a567d60a2da53c9645b7e6c21eeb437bf Mon Sep 17 00:00:00 2001 From: Jayant Date: Mon, 9 Sep 2024 20:16:53 +0800 Subject: [PATCH] fix: moduledata bugs (#27) --- pkg/proc/heap.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/proc/heap.go b/pkg/proc/heap.go index 6441d4a..4f6a427 100644 --- a/pkg/proc/heap.go +++ b/pkg/proc/heap.go @@ -162,13 +162,11 @@ func (s *HeapScope) readHeap() error { spans, spanInfos := s.readAllSpans(mheap.Field("allspans").Array(), spanInUse, kindSpecialFinalizer) // start read arenas - if s.readArenas(mheap) { - return nil + if !s.readArenas(mheap) { + // read typed pointers when enabled alloc header + s.readTypePointers(spans, spanInfos) } - // read typed pointers when enabled alloc header - s.readTypePointers(spans, spanInfos) - // read firstmoduledata return s.readModuleData() } @@ -560,8 +558,8 @@ func (s *HeapScope) readModuleData() error { firstmoduledata := toRegion(tmp, s.bi) for md := firstmoduledata; md.a != 0; md = md.Field("next").Deref() { var data, bss segment - data.init(Address(firstmoduledata.Field("data").Uintptr()), Address(firstmoduledata.Field("edata").Uintptr())) - bss.init(Address(firstmoduledata.Field("bss").Uintptr()), Address(firstmoduledata.Field("ebss").Uintptr())) + data.init(Address(md.Field("data").Uintptr()), Address(md.Field("edata").Uintptr())) + bss.init(Address(md.Field("bss").Uintptr()), Address(md.Field("ebss").Uintptr())) s.data = append(s.data, &data) s.bss = append(s.bss, &bss) }