Closed
Description
What version of Go are you using (go version
)?
$ go version go version devel go1.21-993707a9d6 Tue May 30 20:19:54 2023 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
linux/amd64
What did you do?
For a toy program "hello.go" (hi mom or equivalent), run this script:
#!/bin/sh
go build -cover -o hello.exe hello.go
rm -rf first.cover second.cover
mkdir first.cover second.cover
GOCOVERDIR=first.cover ./hello.exe
GOCOVERDIR=second.cover ./hello.exe
go tool covdata subtract -i=first.cover,second.cover -o=/tmp
go tool covdata subtract -i=second.cover,first -o=/tmp
What did you expect to see?
Clean run.
What did you see instead?
For one of the "go tool covdata" runs, failure with
panic: decreasing dir index, internal error
goroutine 1 [running]:
main.(*sstate).BeginCounterDataFile(0xc0000f61e0, {0xc0000262a0?, 0x55b5a0?}, 0xc0000f6570?, 0x0)
/goroot/src/cmd/covdata/subtractintersect.go:119 +0x388
cmd/internal/cov.(*CovDataReader).visitPod(0xc0000d7ee0, {{0xc00001e280, 0x35}, {0xc0000e4200, 0x2, 0x2}, {0xc000012490, 0x2, 0x2}, {0xc0000124a0, ...}})
/goroot/src/cmd/internal/cov/readcovdata.go:226 +0x7c9
cmd/internal/cov.(*CovDataReader).Visit(0xc0000d7ee0)
/goroot/src/cmd/internal/cov/readcovdata.go:140 +0x165
main.main()
/goroot/src/cmd/covdata/covdata.go:218 +0x8b4
This is due to a flaw in the internal/coverage/pods package, which is sorting coverage counter data files during pod collection based purely on name. This is a problem because counter file names are formed with process IDs, which are chosen by the OS in a non-predictable way.