Skip to content

cmd/{go,cover}: errors on 'go test -covermode=atomic sync/atomic' #57445

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

Closed
thanm opened this issue Dec 22, 2022 · 1 comment
Closed

cmd/{go,cover}: errors on 'go test -covermode=atomic sync/atomic' #57445

thanm opened this issue Dec 22, 2022 · 1 comment
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 Dec 22, 2022

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

$ go version
go version devel go1.20-fadd77c05b Wed Dec 21 20:18:10 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes. In fact it seems to go back quite a ways (I tried with older releases back to 1.8, which also seems to have this problem, then eventually gave up).

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

linux/amd64

What did you do?

$ GOMAXPROCS=1 go test -covermode=atomic sync/atomic

What did you expect to see?

Either a test run or an error of some sort.

What did you see instead?

Go command crashes after running out of stack space, e.g.

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc024e80388 stack=[0xc024e80000, 0xc044e80000]
fatal error: stack overflow
...
cmd/go/internal/work.(*Builder).NewObjdir(0xc0001cedc0)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:373 +0x65 fp=0xc024e806f0 sp=0xc024e80688 pc=0x8c12e5
cmd/go/internal/work.(*Builder).CompileAction.func1()
	/ssd2/xgo/src/cmd/go/internal/work/action.go:454 +0x46 fp=0xc024e80788 sp=0xc024e806f0 pc=0x8c1dc6
cmd/go/internal/work.(*Builder).cacheAction(0xc0001cedc0, {0xa39c79, 0x5}, 0xc000230580, 0xc024e80808)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:416 +0x79 fp=0xc024e807d0 sp=0xc024e80788 pc=0x8c1a19
cmd/go/internal/work.(*Builder).CompileAction(0xc0001cedc0, 0x0?, 0xc024e808b8?, 0x451dc6?)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:449 +0x95 fp=0xc024e80838 sp=0xc024e807d0 pc=0x8c1bf5
cmd/go/internal/work.(*Builder).CompileAction.func1()
	/ssd2/xgo/src/cmd/go/internal/work/action.go:459 +0x15a fp=0xc024e808d0 sp=0xc024e80838 pc=0x8c1eda
cmd/go/internal/work.(*Builder).cacheAction(0xc0001cedc0, {0xa39c79, 0x5}, 0xc000230580, 0xc024e80950)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:416 +0x79 fp=0xc024e80918 sp=0xc024e808d0 pc=0x8c1a19
cmd/go/internal/work.(*Builder).CompileAction(0xc0001cedc0, 0x0?, 0xc024e80a00?, 0x451dc6?)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:449 +0x95 fp=0xc024e80980 sp=0xc024e80918 pc=0x8c1bf5
cmd/go/internal/work.(*Builder).CompileAction.func1()
	/ssd2/xgo/src/cmd/go/internal/work/action.go:459 +0x15a fp=0xc024e80a18 sp=0xc024e80980 pc=0x8c1eda
cmd/go/internal/work.(*Builder).cacheAction(0xc0001cedc0, {0xa39c79, 0x5}, 0xc000230580, 0xc024e80a98)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:416 +0x79 fp=0xc024e80a60 sp=0xc024e80a18 pc=0x8c1a19
cmd/go/internal/work.(*Builder).CompileAction(0xc0001cedc0, 0x0?, 0xc024e80b48?, 0x451dc6?)
	/ssd2/xgo/src/cmd/go/internal/work/action.go:449 +0x95 fp=0xc024e80ac8 sp=0xc024e80a60 pc=0x8c1bf5
...

Similar deal with 1.19. For much older releases it appears we get into some sort of infinite loop? Not sure exactly (but not sure it matters either). It seems likely that we're trying to build a version of sync/atomic that imports itself.

Looking at the code in cmd/go, it is clear that there is code that tries to prevent this scenario, but I think what's going on here is that the existing code is focused too much on the case where sync/atomic is added in as a dependency, as opposed to being the thing called out on the command line as the test target.

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 22, 2022
@thanm thanm self-assigned this Dec 22, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/459335 mentions this issue: cmd/{go/cover}: fix problems with "go test -covermode=atomic sync/atomic"

@dmitshur dmitshur added this to the Go1.20 milestone Jan 9, 2023
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 9, 2023
@golang golang locked and limited conversation to collaborators Jan 9, 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

3 participants