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/cover: coverage instrumentation causes diff in gcflags=-m output #56475

Closed
thanm opened this issue Oct 28, 2022 · 1 comment
Closed

cmd/cover: coverage instrumentation causes diff in gcflags=-m output #56475

thanm opened this issue Oct 28, 2022 · 1 comment
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented Oct 28, 2022

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

$ go version
go version devel go1.20-d398025345 Fri Oct 28 11:18:38 2022 -0400 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?

With this package:

package tiny

func Simple(x int) int {
	if x != 42 {
		return 42
	}
	return 42
}

func CallSimple() int {
	return Simple(42)
}

Do a build with "go build -gcflags=-m tiny" and then with "go build -gcflags=-m -cover tiny"

What did you expect to see?

Same "-m" output

What did you see instead?

The addition of "-cover" perturbs some of the output.

Here's the baseline (no "-cover"):

# cov.example/tiny
./tiny.go:3:6: can inline Simple
./tiny.go:10:6: can inline CallSimple
./tiny.go:11:15: inlining call to Simple

and here is with "-cover":

# cov.example/tiny
./tiny.go:3: can inline Simple
./tiny.go:10: can inline CallSimple
./tiny.go:11: inlining call to Simple

Note that we've lost the column information.

FWIW, this same problem seems to exist for "go test -cover" in previous versions of Go, so this doesn't appear to be a regression.

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 28, 2022
@thanm thanm self-assigned this Oct 28, 2022
@thanm thanm added this to the Go1.20 milestone Oct 28, 2022
@gopherbot
Copy link

Change https://go.dev/cl/446259 mentions this issue: cmd/cover: fix buglet causing differences in -m output

romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Nov 3, 2022
Use a slightly different line number pragma when emitting instrumented
code, so as to ensure that we don't get any changes in the
"-gcflags=-m" output for coverage vs non-coverage.

Fixes golang#56475.

Change-Id: I3079171fdf83c0434ed6ea0ce3eb2797c2280c55
Reviewed-on: https://go-review.googlesource.com/c/go/+/446259
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants