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: ICE with assertion failed when using GODEBUG=gotypesalias=1 #65893

Closed
Jorropo opened this issue Feb 23, 2024 · 19 comments
Closed

cmd/compile: ICE with assertion failed when using GODEBUG=gotypesalias=1 #65893

Jorropo opened this issue Feb 23, 2024 · 19 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@Jorropo
Copy link
Member

Jorropo commented Feb 23, 2024

Go version

go version devel go1.23-d2c49a55be Thu Feb 22 20:02:36 2024 +0700 X:rangefunc linux/amd64 (this has https://go-review.googlesource.com/c/go/+/565995 checked out because I was running into #65778 too)

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/hugo/.cache/go-build'
GOENV='/home/hugo/.config/go/env'
GOEXE=''
GOEXPERIMENT='rangefunc'
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/hugo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/hugo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/hugo/k/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/hugo/k/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-d2c49a55be Thu Feb 22 20:02:36 2024 +0700 X:rangefunc'
GCCGO='/usr/bin/gccgo'
GOAMD64='v3'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/hugo/k/go-libp2p/go.mod'
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 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2580004202=/tmp/go-build -gno-record-gcc-switches'

What did you do?

cd (mktemp -d)
pushd .
mkdir go && cd go
git init && git fetch --depth 1 https://go.googlesource.com/go refs/changes/95/565995/3 && git checkout -b change-565995 FETCH_HEAD
cd src
./make.bash
popd
git clone -b v0.33.0 --depth 1 https://github.com/libp2p/go-libp2p && cd go-libp2p
GODEBUG=gotypesalias=1 ../go/bin/go build .

What did you see happen?

# google.golang.org/protobuf/reflect/protoreflect
/home/hugo/go/pkg/mod/google.golang.org/protobuf@v1.32.0/reflect/protoreflect/value.go:163:6: internal compiler error: assertion failed

goroutine 1 [running]:
runtime/debug.Stack()
	/tmp/go/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0xb1ec80?, 0xc0?}, {0xdf5168, 0x10}, {0x0, 0x0, 0x0})
	/tmp/go/src/cmd/compile/internal/base/print.go:225 +0x1d7
cmd/compile/internal/base.Fatalf(...)
	/tmp/go/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/base.Assert(...)
	/tmp/go/src/cmd/compile/internal/base/print.go:237
cmd/compile/internal/noder.assert(...)
	/tmp/go/src/cmd/compile/internal/noder/stencil.go:15
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:430
cmd/compile/internal/noder.(*reader).typWrapped(0xc000b1eb40, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*reader).doTyp(0xc000b1eb40)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:516 +0x1af
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a9af00, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*reader).param(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:622
cmd/compile/internal/noder.(*reader).params(0xc000a9af00)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:615 +0x50
cmd/compile/internal/noder.(*reader).signature(0xc000a9af00, 0xc000b20140)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:603 +0x5c
cmd/compile/internal/noder.(*reader).interfaceType(0xc000a9af00)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:574 +0x16a
cmd/compile/internal/noder.(*reader).doTyp(0xc000a9af00)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:524 +0x36e
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a9ab40, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*pkgReader).objIdxMayFail(0xc00089a0e0, 0x10, {0x0, 0x0, 0x0}, {0x15928e0, 0x0, 0x0}, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:805 +0x53c
cmd/compile/internal/noder.(*pkgReader).objIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:670
cmd/compile/internal/noder.(*pkgReader).objInstIdx(0xc00089a0e0, {0xffffffff?, {0x15928e0?, 0xc000a9a640?, 0xc000a87ef0?}}, 0xc000a7bad0, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:662 +0xe7
cmd/compile/internal/noder.(*reader).obj(0xc000a9a780)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:634 +0x46
cmd/compile/internal/noder.(*reader).doTyp(0xc000a9a780)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:500 +0x72
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a9a640, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*reader).structType(0xc000a9a640)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:589 +0x90
cmd/compile/internal/noder.(*reader).doTyp(0xc000a9a640)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:522 +0x35a
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a9a3c0, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*pkgReader).objIdxMayFail(0xc00089a0e0, 0x51, {0x0, 0x0, 0x0}, {0x15928e0, 0x0, 0x0}, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:744 +0xca6
cmd/compile/internal/noder.(*pkgReader).objIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:670
cmd/compile/internal/noder.(*pkgReader).objInstIdx(0xc00089a0e0, {0xffffffff?, {0x15928e0?, 0xc00064efc8?, 0xbcee0e?}}, 0xc000a7b790, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:662 +0xe7
cmd/compile/internal/noder.(*reader).obj(0xc000a9a000)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:634 +0x46
cmd/compile/internal/noder.(*reader).doTyp(0xc000a9a000)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:500 +0x72
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a97e00, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*reader).param(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:622
cmd/compile/internal/noder.(*reader).params(0xc000a97e00)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:615 +0x50
cmd/compile/internal/noder.(*reader).signature(0xc000a97e00, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:602 +0x45
cmd/compile/internal/noder.(*reader).doTyp(0xc000a97e00)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:518 +0x347
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a96b40, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*reader).structType(0xc000a96b40)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:589 +0x90
cmd/compile/internal/noder.(*reader).doTyp(0xc000a96b40)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:522 +0x35a
cmd/compile/internal/noder.(*pkgReader).typIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:429
cmd/compile/internal/noder.(*reader).typWrapped(0xc000a96780, 0x1)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:388 +0x4e
cmd/compile/internal/noder.(*reader).typ(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:382
cmd/compile/internal/noder.(*pkgReader).objIdxMayFail(0xc00089a0e0, 0x4e, {0x0, 0x0, 0x0}, {0x15928e0, 0x0, 0x0}, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:744 +0xca6
cmd/compile/internal/noder.(*pkgReader).objIdx(...)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:670
cmd/compile/internal/noder.(*pkgReader).objInstIdx(0xc00089a0e0, {0x46060a?, {0x15928e0?, 0x45fe49?, 0x8?}}, 0x0, 0x0)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:662 +0xe7
cmd/compile/internal/noder.(*reader).obj(0xc000a76280)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:634 +0x46
cmd/compile/internal/noder.(*reader).pkgObjs(0xc000a76280, 0xc000002240)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:3331 +0x9d
cmd/compile/internal/noder.(*reader).pkgDecls(0xc000a76280, 0xc000002240)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:3320 +0x18f
cmd/compile/internal/noder.(*reader).pkgInit(0xc000a76280, 0xc00008c320?, 0xc000002240)
	/tmp/go/src/cmd/compile/internal/noder/reader.go:3226 +0xe5
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0xc0003a8690?, 0xd32380?, 0x0?})
	/tmp/go/src/cmd/compile/internal/noder/unified.go:188 +0x17c
cmd/compile/internal/noder.LoadPackage({0xc0000222a0, 0x9, 0xa})
	/tmp/go/src/cmd/compile/internal/noder/noder.go:77 +0x43a
cmd/compile/internal/gc.Main(0xe24a40)
	/tmp/go/src/cmd/compile/internal/gc/main.go:197 +0xbbd
main.main()
	/tmp/go/src/cmd/compile/main.go:57 +0xf9

What did you expect to see?

Nothing (the build succeed)

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 23, 2024
@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

This looks like a different bug than #65778 with a similar root cause (spurious unhandled *Alias nodes in the types).

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

This looks like a different bug than #65778 with a similar root cause (spurious unhandled *Alias nodes in the types).

I think it is.

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

Duplicated of #65778

@cuonglm cuonglm closed this as completed Feb 23, 2024
@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

@cuonglm then https://go.dev/cl/565995 doesn't fix #65778

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

@cuonglm then https://go.dev/cl/565995 doesn't fix #65778

Hmm, it's strange. Could you please show me the error output?

@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

@cuonglm this in my original message.
If you look at:

What did you do?

it shows I first checkout your cl.
Then:

What did you see happen?

Shows the panic.

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

@Jorropo No, I mean you said it does not fix #65778, then what the error output when you build with https://go.dev/cl/565995?

I'm AFK FYI.

@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

I don't get what you mean, I built with https://go.dev/cl/565995 from the start.

What I meant is that if this issue is a dup of #65778 like you are saying then https://go.dev/cl/565995 is not fixing #65778 because I still can't build even after applying your patch. (more exactly I go from the exact same panic stack trace as #65778 before applying https://go.dev/cl/565995 to a different panic stack trace after applying that why I don't think it's the same bug)

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

@Jorropo It does fix #65778, build ok for me after applying https://go.dev/cl/565995.

@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

what builds ok ?

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

what builds ok ?

The garble repo: https://github.com/mvdan/garble-fork

@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

Yeah but my code doesn't, so why did you closed this issue ?

google.golang.org/protobuf/reflect/protoreflect to be precise

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

Yeah but my code doesn't, so why did you closed this issue ?

@cuonglm cuonglm reopened this Feb 23, 2024
@Jorropo
Copy link
Member Author

Jorropo commented Feb 23, 2024

Oh I see what happen, I have two bugs (or more idk) go.uber.org/zap is the other repro #65778 which is fixed by https://go.dev/cl/565995. Once I checkout CL 565995 go.uber.org/zap builds and so my code fails to build later down the line when reaching google.golang.org/protobuf/reflect/protoreflect (because of the way go build happens to order the compilation steps there).

I am saying that your CL doesn't fix #65778 in response to you claiming this is a duplicate. IMO what is happening with google.golang.org/protobuf/reflect/protoreflect is a different bug and your CL fix #65778. 🙂
I wanted to draw your attention to the fact you closed this issue even tho the proposed fix to the issue you claim is a duplicate does not work to fix my problem.

@cuonglm cuonglm self-assigned this Feb 23, 2024
@cuonglm cuonglm added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 23, 2024
@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

Minimal reproducer:

package p

type (
	s  = struct{ f func(s1) }
	s1 = struct{ i I }
)

type I interface {
	S() *s
}

@cuonglm
Copy link
Member

cuonglm commented Feb 23, 2024

It's interesting that changing the order of type definition makes the code compiled (with https://go-review.googlesource.com/c/go/+/565995 applied):

package p

type I interface {
	S() *s
}

type (
	s  = struct{ f func(s1) }
	s1 = struct{ i I }
)

cc @mdempsky

@mknyszek mknyszek changed the title cmd/compile: yet an other ICE with assertion failed when using GODEBUG=gotypesalias=1 cmd/compile: ICE with assertion failed when using GODEBUG=gotypesalias=1 Feb 28, 2024
@mknyszek mknyszek added this to the Backlog milestone Feb 28, 2024
@mknyszek
Copy link
Contributor

CC @mdempsky

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/568455 mentions this issue: cmd/compile: use the index of actual aliased type if existed

@dmitshur
Copy link
Contributor

dmitshur commented Apr 2, 2024

This seems to also happen at tip (commit 94dba61) if attempting to make.bash with GODEBUG=gotypesalias=1.

src $ git pull --ff-only 
Already up to date.

src $ ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.1 darwin/arm64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.
---
Installed Go for darwin/arm64 in /Users/gopher/gotip
Installed commands in /Users/gopher/gotip/bin
*** You need to add /Users/gopher/gotip/bin to your PATH.

src $ GODEBUG=gotypesalias=1 ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.1 darwin/arm64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
# cmd/compile/internal/syntax
/Users/gopher/gotip/src/cmd/compile/internal/syntax/tokens.go:7:6: internal compiler error: assertion failed

goroutine 1 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x64
bootstrap/cmd/compile/internal/base.FatalfAt({0x7fc4e0?, 0x140?}, {0x104d7556e, 0x10}, {0x0, 0x0, 0x0})
	/Users/gopher/gotip/src/cmd/compile/internal/base/print.go:225 +0x1fc
bootstrap/cmd/compile/internal/base.Fatalf(...)
	/Users/gopher/gotip/src/cmd/compile/internal/base/print.go:194
bootstrap/cmd/compile/internal/base.Assert(...)
	/Users/gopher/gotip/src/cmd/compile/internal/base/print.go:237
bootstrap/cmd/compile/internal/noder.assert(...)
	/Users/gopher/gotip/src/cmd/compile/internal/noder/stencil.go:15
bootstrap/cmd/compile/internal/noder.(*pkgReader).typIdx(0x140006636c0, {0x100370?, 0x40?}, 0x1400136c410, 0x1)
	/Users/gopher/gotip/src/cmd/compile/internal/noder/reader.go:430 +0x1a4
bootstrap/cmd/compile/internal/noder.(*reader).typWrapped(0x14001363a40, 0x1)
	/Users/gopher/gotip/src/cmd/compile/internal/noder/reader.go:388 +0x54
bootstrap/cmd/compile/internal/noder.(*reader).typ(...)
[...]
bootstrap/cmd/compile/internal/gc.Main(0x104f720e0)
	/Users/gopher/gotip/src/cmd/compile/internal/gc/main.go:197 +0xafc
main.main()
	/Users/gopher/gotip/src/cmd/compile/main.go:57 +0x110

go tool dist: FAILED: /Users/gopher/gotip/pkg/tool/darwin_arm64/go_bootstrap install -pgo=off cmd/asm cmd/cgo cmd/compile cmd/link: exit status 1

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. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

5 participants