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: unreachable code causes internal compiler error #65680

Closed
jrick opened this issue Feb 12, 2024 · 5 comments
Closed

cmd/compile: unreachable code causes internal compiler error #65680

jrick opened this issue Feb 12, 2024 · 5 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@jrick
Copy link
Contributor

jrick commented Feb 12, 2024

Go version

go version go1.22.0 openbsd/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jrick/.cache/go-build'
GOENV='/home/jrick/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='openbsd'
GOINSECURE=''
GOMODCACHE='/home/jrick/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='openbsd'
GOPATH='/home/jrick/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/jrick/src/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/jrick/src/go/pkg/tool/openbsd_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3442254126=/tmp/go-build -gno-record-gcc-switches'

What did you do?

https://go.dev/play/p/NHe6QNjlr_i

What did you see happen?

CLOSURE [prog.go:13:9:var n int]
<unknown line number>: internal compiler error: assertion failed

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

What did you expect to see?

No build error (except for unreachable code warnings from vet).

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 12, 2024
@thanm
Copy link
Contributor

thanm commented Feb 12, 2024

Thanks for the report.

cc @golang/compiler

@jrick
Copy link
Contributor Author

jrick commented Feb 13, 2024

this also affects non-loop labels https://go.dev/play/p/ylEUvtiBb1X

@jrick
Copy link
Contributor Author

jrick commented Feb 13, 2024

the general pattern here seems to be:

  1. early unconditional return
  2. declare a variable
  3. declare a label
  4. use the variable after the label. assignments to _ will trigger the bug. For loop labels, the variable usage can occur either inside the loop, or after.

We hit this in our "real code" due to an early unconditional return that was added near the top of a function to stub out something that wasn't ready yet.

@jrick jrick changed the title cmd/go: unreachable code causes internal compiler error cmd/compile: unreachable code causes internal compiler error Feb 13, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 13, 2024
@thanm
Copy link
Contributor

thanm commented Feb 14, 2024

Duplicate of #65593?

@jrick
Copy link
Contributor Author

jrick commented Feb 15, 2024

Yes, appears to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. 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

3 participants