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: internal compiler error: unknown op in select ASOP #57641

Closed
jeremybobbin opened this issue Jan 5, 2023 · 2 comments
Closed

cmd/compile: internal compiler error: unknown op in select ASOP #57641

jeremybobbin opened this issue Jan 5, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge

Comments

@jeremybobbin
Copy link

jeremybobbin commented Jan 5, 2023

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

$ go version
go version go1.19.4 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/founder/.cache/go-build"
GOENV="/home/founder/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/founder/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/founder/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.19"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.19/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/founder/mvd/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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1143537869=/tmp/go-build -gno-record-gcc-switches"

What did you do?

The project I'm working on is proprietary unfortunately & my laptop is about to die so you won't be getting a minimum viable bug replication today. :(
However, I believe this is the bit that caused the compiler error:

        total := func() int64 {
                var total int64
                var dones int
                for {
                        select {
                        case total += <-sizes:
                        case <-done:
                                dones += 1
                                if dones == len(o) {
                                        return total
                                }
                        }
                }

        }()

What did you expect to see?

I was expecting to see a type error or syntax related error, or maybe even no compilation errors at all!!

What did you see instead?

It asks me to "Please file a bug report including a short program that triggers the error."
Not sure if this is supposed to make my code compile?

Compiling the (proprietary) project results in:

# mvd
select case
.   ASOP-ADD AsOp:ADD tc(1) # overlay.go:158:15,overlay.go:167:3
.   .   NAME-main.total esc(no) Class:PAUTO Offset:0 InlLocal OnStack Used int64 tc(1) # overlay.go:154:7,overlay.go:167:3
.   .   RECV int64 tc(1) # overlay.go:158:18,overlay.go:167:3
.   .   .   NAME-main.sizes esc(no) Class:PAUTO Offset:0 Byval OnStack CHAN-chan int64 tc(1) # overlay.go:133:2
./overlay.go:167:3: internal compiler error: unknown op in select ASOP

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

I've pacified the compiler by doing:

  case size := <-sizes:
     total += size

instead of:

  case size += <-sizes:

Sad!

@seankhliao seankhliao changed the title affected/package: cmd/compile: internal compiler error: unknown op in select ASOP Jan 5, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 5, 2023
@ianlancetaylor
Copy link
Contributor

Thanks. Here is a complete test case that reproduces the problem in Go 1.19:

package p

func F(c1, c2 chan int) int {
	var total int
	select {
	case total += <-c1:
	case <-c2:
	}
	return total
}

In Go 1.20 this prints

foo.go:6:13: select case must be receive, send or assign recv

This code is invalid so this is basically a really bad error message in Go 1.19. Since it's fixed in Go 1.20, and since I don't think we should backport the fix, I'm going to close this issue. Thanks for reporting the problem.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2023
@golang golang locked and limited conversation to collaborators Jan 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants