Skip to content

cmd/compile: internal compiler error: assertion failed [1.18 backport] #53852

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
dmgk opened this issue Jul 13, 2022 · 9 comments
Closed

cmd/compile: internal compiler error: assertion failed [1.18 backport] #53852

dmgk opened this issue Jul 13, 2022 · 9 comments
Assignees
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Milestone

Comments

@dmgk
Copy link
Member

dmgk commented Jul 13, 2022

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

$ go version
go version go1.18.4 freebsd/amd64

Does this issue reproduce with the latest release?

This seems to be a regression in go1.18.4.
Both go1.18.3 and the current tip (go version devel go1.19-c006b7ac27 Wed Jul 13 18:35:00 2022 +0000 freebsd/amd64) do not have this issue.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dg/.cache/go-build"
GOENV="/home/dg/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/dg/.gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/dg/.gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/dg/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/dg/opt/go/pkg/tool/freebsd_amd64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/home/dg/tmp/gopass/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1954080416=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ git clone https://github.com/gopasspw/gopass.git
$ cd gopass
$ go build -gcflags=-d=panic ./...

What did you expect to see?

A successful build.

What did you see instead?

# github.com/gopasspw/gopass/internal/backend
internal/backend/registry.go:85:45: internal compiler error: assertion failed

goroutine 1 [running]:
runtime/debug.Stack()
	/home/dg/opt/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x839d70?, 0xc0?}, {0xd297e9, 0x10}, {0x0, 0x0, 0x0})
	/home/dg/opt/go/src/cmd/compile/internal/base/print.go:227 +0x1d7
cmd/compile/internal/base.Fatalf(...)
	/home/dg/opt/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/base.Assert(...)
	/home/dg/opt/go/src/cmd/compile/internal/base/print.go:239
cmd/compile/internal/noder.assert(...)
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:27
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe9ac10, 0xc00087b9e0})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1307 +0x1e7
cmd/compile/internal/ir.(*SelectorExpr).editChildren(0xc0008519e0, 0xc000885940)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:1106 +0x62
cmd/compile/internal/ir.EditChildren(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe9a440, 0xc0008519e0})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1219 +0x74
cmd/compile/internal/ir.(*CallExpr).editChildren(0xc00085d440, 0xc000885940)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:274 +0x64
cmd/compile/internal/ir.EditChildren(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe98758, 0xc00085d440})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1219 +0x74
cmd/compile/internal/ir.(*BinaryExpr).editChildren(0xc000851980, 0xc000885940)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:204 +0x62
cmd/compile/internal/ir.EditChildren(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe98500, 0xc000851980})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1219 +0x74
cmd/compile/internal/ir.editNodes(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:1521
cmd/compile/internal/ir.(*ReturnStmt).editChildren(0xc0008688c0?, 0xc000885940)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:1056 +0xa2
cmd/compile/internal/ir.EditChildren(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe9a2b0, 0xc000868a00})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1219 +0x74
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe989b0, 0xc000868820})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1230 +0x95b
cmd/compile/internal/ir.editNodes(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:1521
cmd/compile/internal/ir.(*CallExpr).editChildren(0xc00085d3b0, 0xc000885940)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:276 +0x1c2
cmd/compile/internal/ir.EditChildren(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe98758, 0xc00085d3b0})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1219 +0x74
cmd/compile/internal/ir.editNodes(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/node_gen.go:1521
cmd/compile/internal/ir.(*Func).editChildren(0xc0007794e0?, 0xc000885940?)
	/home/dg/opt/go/src/cmd/compile/internal/ir/func.go:157 +0x74
cmd/compile/internal/ir.EditChildren(...)
	/home/dg/opt/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/noder.(*genInst).dictPass.func1({0xe990b8, 0xc000842c60})
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1219 +0x74
cmd/compile/internal/noder.(*genInst).dictPass(0x1399780, 0xc000839bf0)
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:1365 +0x126
cmd/compile/internal/noder.(*genInst).buildInstantiations(0x1399780)
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:78 +0x1d2
cmd/compile/internal/noder.BuildInstantiations(...)
	/home/dg/opt/go/src/cmd/compile/internal/noder/stencil.go:44
cmd/compile/internal/noder.(*irgen).generate(0xc00037a480, {0xc0003fef00, 0x6, 0x203000?})
	/home/dg/opt/go/src/cmd/compile/internal/noder/irgen.go:331 +0x3d1
cmd/compile/internal/noder.check2({0xc0003fef00, 0x6, 0x6})
	/home/dg/opt/go/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc0000c6120, 0x6, 0x0?})
	/home/dg/opt/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0xd51b20)
	/home/dg/opt/go/src/cmd/compile/internal/gc/main.go:191 +0xb13
main.main()
	/home/dg/opt/go/src/cmd/compile/main.go:55 +0xdd

See also #53762

cc @golang/compiler

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@dmgk
Copy link
Member Author

dmgk commented Jul 14, 2022

460a93b seems to be the culprit, reverting it fixes the build.

@cuonglm
Copy link
Member

cuonglm commented Jul 14, 2022

It's weird that checkout 7eeec1f on master branch works.

@cuonglm
Copy link
Member

cuonglm commented Jul 14, 2022

So I think the problem is that with the master, we use method expression closures to implement bound method calls, which is implemented in 2 CLs:

So the bound method calls in:

func (r *Registry[K, V]) Prioritized() []V {
	bes := maps.Values(r.backends)
	sort.Slice(bes, func(i, j int) bool {
		return bes[i].Priority() < bes[j].Priority()
	})

	return bes
}

is not cast anymore.

I'm not sure what should we do in this case, cherry pick those 2 CLs? cc @randall77 @mdempsky

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 14, 2022
@mknyszek mknyszek added this to the Backlog milestone Jul 14, 2022
@mdempsky
Copy link
Contributor

I think let's revert the backport CL. Go 1.19 will be out soon, and I think it's more important in the mean time that we don't destabilize the Go 1.18 release branch.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/417615 mentions this issue: Revert "[release-branch.go1.18] cmd/compile: fix missing dict pass for type assertions"

@dmitshur
Copy link
Member

@mknyszek @mdempsky This issue is currently in Backlog milestone, which probably needs updating. Do you think it's better to move this issue to Go1.19 milestone and close it (since it's fixed at tip) and ask gopherbot to file a backport issue for 1.18 which will create an issue in the right milestone—or would it work better to just manually edit this issue to be a Go 1.18 backport issue?

@mdempsky mdempsky modified the milestones: Backlog, Go1.20, Go1.18.5 Jul 14, 2022
@mdempsky
Copy link
Contributor

@dmitshur The issue here is exclusive to the Go 1.18 release branch, as far as I can tell, so I've assigned to 1.18.5.

We discussed this internally amongst the Google Go compiler and runtime team, and consensus is to simply revert any problematic backported CLs and stop backporting further generics CLs to 1.18. It's unfortunate that 1.18.* will continue having generics correctness issues, but we think it's better those issues remain stable across point releases so users can reliably upgrade to get security fixes.

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 14, 2022
Revert https://go-review.googlesource.com/c/go/+/411617 that introduced
the regression that broke security/gopass and
security/git-credential-gopass.

See golang/go#53852 for more details.
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Jul 14, 2022
Revert https://go-review.googlesource.com/c/go/+/411617 that introduced
the regression that broke security/gopass and
security/git-credential-gopass.

See golang/go#53852 for more details.

Approved by:	portmgr blanket (build fix)

(cherry picked from commit e57c55d)
@williamh
Copy link

This is also an issue on go version go1.18.4 linux/amd64. You can use the same repo mentioned for FreeBSD to get the error on Linux.

@toothrot toothrot added the CherryPickApproved Used during the release process for point releases label Jul 20, 2022
@toothrot toothrot changed the title cmd/compile: internal compiler error: assertion failed cmd/compile: internal compiler error: assertion failed [1.18 backport] Jul 20, 2022
@dmitshur dmitshur removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 20, 2022
@mknyszek mknyszek moved this to In Progress in Go Compiler / Runtime Jul 20, 2022
@mknyszek mknyszek moved this from In Progress to All-But-Submitted in Go Compiler / Runtime Jul 20, 2022
ernado added a commit to go-faster/x that referenced this issue Jul 21, 2022
ernado added a commit to ClickHouse/ch-go that referenced this issue Jul 21, 2022
corpix added a commit to corpix/nixpkgs that referenced this issue Jul 21, 2022
@gopherbot
Copy link
Contributor

Closed by merging 6ff8801 to release-branch.go1.18.

Repository owner moved this from All-But-Submitted to Done in Go Compiler / Runtime Jul 27, 2022
gopherbot pushed a commit that referenced this issue Jul 27, 2022
…r type assertions"

This reverts CL 411934 (commit 460a93b).

Fixes #53852.
Updates #53357.

Change-Id: I93d7015d8962d22ffd73128b038e4e7e7ca41c2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/417615
Run-TryBot: Cherry Mui <[email protected]>
Reviewed-by: Cuong Manh Le <[email protected]>
Reviewed-by: David Chase <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
@dmgk dmgk mentioned this issue Aug 1, 2022
@golang golang locked and limited conversation to collaborators Jul 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

8 participants