Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/covdata: subtract operation incorrectly sensitive to process IDs #60526

Closed
thanm opened this issue May 30, 2023 · 1 comment
Closed

cmd/covdata: subtract operation incorrectly sensitive to process IDs #60526

thanm opened this issue May 30, 2023 · 1 comment
Assignees
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented May 30, 2023

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.

@thanm thanm added this to the Go1.21 milestone May 30, 2023
@thanm thanm self-assigned this May 30, 2023
@thanm thanm added the Tools This label describes issues relating to any tools in the x/tools repository. label May 30, 2023
@gopherbot
Copy link

Change https://go.dev/cl/499317 mentions this issue: internal/coverage/pods: sort counter data files first by origin, then name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants