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

sync/atomic: compare and swap of inconsistently typed values with uninitialized Value #52612

Closed
wwade opened this issue Apr 28, 2022 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@wwade
Copy link

wwade commented Apr 28, 2022

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

$ go version
go version go1.18.1 linux/amd64

Does this issue reproduce with the latest release?

Yes. 1.18 and tip on play. Not in 1.17.9. Also docker run golang:1.18.1 .

This does appear to be a regression from 3a0cd11. In CompareAndSwap it's not checking against firstStoreInProgress.

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

go env Output
$ docker run --rm -it -v $PWD:$PWD -w $PWD golang:1.18.1 go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/repro/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1501168033=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://go.dev/play/p/6a28XhlK8iQ

Sometimes it will hit on go.dev/play, more reliably reproduced by running locally.

I can avoid the problem by storing an initial value:

	var av atomic.Value
+ 	av.Store(1)

What did you expect to see?

Successful program execution.

What did you see instead?

panic: sync/atomic: compare and swap of inconsistently typed values

goroutine 14451 [running]:
sync/atomic.(*Value).CompareAndSwap(0xc000204b00?, {0xffffffffffffffff, 0x0}, {0x48fc40, 0x525828})
	/usr/local/go-faketime/src/sync/atomic/value.go:143 +0x17f
main.handleValue(0xc000204b20, 0x1)
	/tmp/sandbox4062856071/prog.go:20 +0xcd
main.dotest.func1(0x0?)
	/tmp/sandbox4062856071/prog.go:37 +0xa5
created by main.dotest
	/tmp/sandbox4062856071/prog.go:50 +0xda

Program exited.
@ianlancetaylor
Copy link
Contributor

CC @randall77

@ianlancetaylor ianlancetaylor added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Apr 28, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Apr 28, 2022
@randall77
Copy link
Contributor

Ah yes, looks like a "race" between my CL 241661, which renamed the first-store-in-progress marker, and CL 241678, which introduced new instances of the old marker. I think we just need to agree on the new one.

@gopherbot Please open a backport issue for 1.18.

@gopherbot
Copy link

Backport issue(s) opened: #52615 (for 1.18).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link

Change https://go.dev/cl/403094 mentions this issue: sync/atomic: use consistent first-store-in-progress marker

@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 May 4, 2022
hzyitc added a commit to hzyitc/go-notify that referenced this issue May 10, 2022
@golang golang locked and limited conversation to collaborators May 4, 2023
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. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants