From: Michael Anthony Knyszek Date: Mon, 20 May 2024 20:18:02 +0000 (+0000) Subject: runtime: correctly account for allocated objects in allocfree trace X-Git-Tag: go1.23rc1~207 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=197101a84a563ee8fb6ac58bb91ab2de49f0cbce;p=gostls13.git runtime: correctly account for allocated objects in allocfree trace The current implementation doesn't handle s.freeindex at all, which means it'll skip a whole bunch of recently-made allocations, because the span may have not been swept yet. Change-Id: I8c5e360f5927ffe7e9abb448b352a59875e31b02 Reviewed-on: https://go-review.googlesource.com/c/go/+/586996 LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Knyszek Reviewed-by: Michael Pratt --- diff --git a/src/runtime/traceallocfree.go b/src/runtime/traceallocfree.go index e1190394ed..3067e16670 100644 --- a/src/runtime/traceallocfree.go +++ b/src/runtime/traceallocfree.go @@ -45,11 +45,10 @@ func traceSnapshotMemory() { // Find all allocated objects. abits := s.allocBitsForIndex(0) for i := uintptr(0); i < uintptr(s.nelems); i++ { - if !abits.isMarked() { - continue + if abits.index < uintptr(s.freeindex) || abits.isMarked() { + x := s.base() + i*s.elemsize + trace.HeapObjectExists(x, s.typePointersOfUnchecked(x).typ) } - x := s.base() + i*s.elemsize - trace.HeapObjectExists(x, s.typePointersOfUnchecked(x).typ) abits.advance() } }