Skip to content

Commit 416347b

Browse files
committed
cmd/viewcore: account for partially allocated arenas
Arenas used to be allocated completely (or at least, have a span allocated to represent the unused space). Since 1.13.3, the latest arena only has spans up to its highest allocation point. Fixes viewcore for 1.13.3. This change was CL 189957, backported to 1.13 at CL 198485. Update golang/go#38638 Change-Id: Ia8cb14925cf6f4226a80e7ff4f011aa93e8b41d1 Reviewed-on: https://go-review.googlesource.com/c/debug/+/232158 Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 21d9a9d commit 416347b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

internal/gocore/gocore_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,5 @@ func TestVersions(t *testing.T) {
269269
loadExampleVersion(t, "1.11")
270270
loadExampleVersion(t, "1.12.zip")
271271
loadExampleVersion(t, "1.13.zip")
272+
loadExampleVersion(t, "1.13.3.zip")
272273
}

internal/gocore/process.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ func (p *Process) readSpans(mheap region, arenas []arena) {
306306
panic("weird mapping " + m.Perm().String())
307307
}
308308
}
309+
if mheap.HasField("curArena") {
310+
// Subtract from the heap unallocated space
311+
// in the current arena.
312+
ca := mheap.Field("curArena")
313+
unused := int64(ca.Field("end").Uintptr() - ca.Field("base").Uintptr())
314+
heap -= unused
315+
all -= unused
316+
}
309317
pageSize := p.rtConstants["_PageSize"]
310318

311319
// Span types

internal/gocore/testdata/1.13.3.zip

719 KB
Binary file not shown.

0 commit comments

Comments
 (0)