Skip to content

Commit 0011342

Browse files
committed
test: ignore MemProfileRecords with no live objects in finprofiled.go
This test erroneously assumes that there will always be at least one live object accounted for in a MemProfileRecord. This is not true; all memory allocated from a particular location could be dead. Fixes #64153. Change-Id: Iadb783ea9b247823439ddc74b62a4c8b2ce8e33e Reviewed-on: https://go-review.googlesource.com/c/go/+/542736 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 22278e3 commit 0011342

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/finprofiled.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func main() {
5757
for _, p := range prof {
5858
bytes := p.AllocBytes - p.FreeBytes
5959
nobj := p.AllocObjects - p.FreeObjects
60+
if nobj == 0 {
61+
// There may be a record that has had all of its objects
62+
// freed. That's fine. Avoid a divide-by-zero and skip.
63+
continue
64+
}
6065
size := bytes / nobj
6166
if size == tinyBlockSize {
6267
totalBytes += bytes

0 commit comments

Comments
 (0)