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/compile: seg fault with generics, channels and closures #51355

Closed
KevinStrong opened this issue Feb 24, 2022 · 6 comments
Closed

cmd/compile: seg fault with generics, channels and closures #51355

KevinStrong opened this issue Feb 24, 2022 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@KevinStrong
Copy link

This bug is re-producable on Go Playground here

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

$ go version go1.18rc1 darwin/amd64

Does this issue reproduce with the latest release?

Yes, go1.18.rc1

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kevinstrong/Library/Caches/go-build"
GOENV="/Users/kevinstrong/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kevinstrong/go/pkg/mod"
GONOPROXY="github.com/merit"
GONOSUMDB="github.com/merit"
GOOS="darwin"
GOPATH="/Users/kevinstrong/go"
GOPRIVATE="github.com/merit"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/kevinstrong/sdk/go1.18rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kevinstrong/sdk/go1.18rc1/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18rc1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/kevinstrong/code/go-sandbox/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/hz/nb5q5m612zl1dkwtzj_jyvvm0000gn/T/go-build3831904386=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Here is link to go playground
It is the same as the link at the top of this post.

What did you expect to see?

The value "test" printed.

What did you see instead?

A segmentation fault.

@KevinStrong KevinStrong changed the title affected/package: seg fault with generics, channels and closures Feb 24, 2022
@mengzhuo mengzhuo changed the title seg fault with generics, channels and closures go/types2: seg fault with generics, channels and closures Feb 25, 2022
@mengzhuo
Copy link
Contributor

CC @griesemer

@mengzhuo mengzhuo changed the title go/types2: seg fault with generics, channels and closures go/types,cmd/compile: seg fault with generics, channels and closures Feb 25, 2022
@mengzhuo mengzhuo added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 25, 2022
@randall77
Copy link
Contributor

Looks like we're capturing the dictionary for use in the go'd closure incorrectly. Instead of putting the dictionary in the closure, we're putting the address of a slot on the stack that contains the dictionary. Of course, that slot is an address on the stack of the caller, which might be long gone by the time the goroutine runs.
Maybe forcing the dictionary to always be captured by value instead of by address would fix it. I thought we already did that, but maybe not.

@griesemer griesemer added this to the Go1.18 milestone Feb 25, 2022
@ianlancetaylor
Copy link
Contributor

This seems to be an incorrect compilation of a valid program, so marking as a release blocker.

CC @danscales

@findleyr
Copy link
Contributor

@randall77 is there evidence that this is related to go/types or types2? Asking due to the issue title.

@randall77
Copy link
Contributor

@findleyr No, this is definitely backend stuff.

@randall77 randall77 changed the title go/types,cmd/compile: seg fault with generics, channels and closures cmd/compile: seg fault with generics, channels and closures Feb 25, 2022
@gopherbot
Copy link

Change https://go.dev/cl/388115 mentions this issue: cmd/compile: ensure dictionary assignment statements are defining statements

@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 Mar 2, 2022
@golang golang locked and limited conversation to collaborators Mar 3, 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

8 participants