Skip to content

Commit 197101a

Browse files
mknyszekgopherbot
authored andcommitted
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 <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 5ab8f90 commit 197101a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/runtime/traceallocfree.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ func traceSnapshotMemory() {
4545
// Find all allocated objects.
4646
abits := s.allocBitsForIndex(0)
4747
for i := uintptr(0); i < uintptr(s.nelems); i++ {
48-
if !abits.isMarked() {
49-
continue
48+
if abits.index < uintptr(s.freeindex) || abits.isMarked() {
49+
x := s.base() + i*s.elemsize
50+
trace.HeapObjectExists(x, s.typePointersOfUnchecked(x).typ)
5051
}
51-
x := s.base() + i*s.elemsize
52-
trace.HeapObjectExists(x, s.typePointersOfUnchecked(x).typ)
5352
abits.advance()
5453
}
5554
}

0 commit comments

Comments
 (0)