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

runtime/coverage: counter mode clash when testing with instrumented go tools #57924

Closed
thanm opened this issue Jan 19, 2023 · 2 comments
Closed
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented Jan 19, 2023

What version of Go are you using (go version)?

$ go version
go version devel go1.20-be7781e3b8 Tue Jan 17 11:52:25 2023 -0500 linux/amd64

Does this issue reproduce with the latest release?

Requires 1.20 or later.

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

While working on a cover.bash script to collect project wide coverage data for Go's std/cmd, I ran into issues when trying to run the equivalent of "go dist test" with coverage enabled and with coverage-instrumented tools (compiler, linker, etc).

Here is a stripped down recipe of the commands being run:

go install -coverpkg=all cmd/compile
D=/tmp/covprofiles
rm -rf $D ; mkdir $D
export GOCOVERDIR=$D
go test -coverpkg=all -race -count=1 -short -run=Output runtime/race

What did you expect to see?

Expected to see a clean -cover run for runtime/race:

ok  	runtime/race	6.505s	coverage: 5.7% of statements in all

What did you see instead?

Final "go test" fails with

# error generating coverage report: internal error: counter mode clash: "atomic" from test harness,
 "set" from data file /tmp/go-build482604180/b001/gocoverdir/covmeta.0ed46d8a48b6014ba4cec613e2eee6ef

What's happening here is that the instrumented compiler is writing out coverage profiles (with mode "set") to the same location that the test is emitting atomic-mode files. This in itself is not necessarily a problem, but it appears that the test harness is picking up pods from the compiler when it is doing its reporting, which should not be happening.

@thanm thanm added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 19, 2023
@thanm thanm added this to the Go1.21 milestone Jan 19, 2023
@thanm thanm self-assigned this Jan 19, 2023
@gopherbot
Copy link

Change https://go.dev/cl/462756 mentions this issue: runtime/coverage: avoid non-test coverage profiles in test report helper

@gopherbot
Copy link

Change https://go.dev/cl/463417 mentions this issue: [release-branch.go1.20] runtime/coverage: avoid non-test coverage profiles in test report helper

gopherbot pushed a commit that referenced this issue Jan 26, 2023
…files in test report helper

When walking through the set of coverage data files generated from a
"go test -cover" run, it's possible to encounter pods (clumps of data
files) that were generated by a run from an instrumented Go tool (for
example, cmd/compile). Add a guard to the test reporting code to
ensure that it only processes files created by the currently running
test.

Fixes #57924.

Change-Id: I1bb7dce88305e1088162e3cb1df628486ecee1c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/462756
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
(cherry picked from commit cf70d37)
Reviewed-on: https://go-review.googlesource.com/c/go/+/463417
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
@golang golang locked and limited conversation to collaborators Jan 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants