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: "panic: interface conversion" when compiling a test that calls a generic function #48094

Closed
bcmills opened this issue Aug 31, 2021 · 7 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Aug 31, 2021

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

~/src/github.com/bcmills/unsafeslice$ gotip version
go version devel go1.18-f118d145a Tue Aug 31 08:41:16 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

N/A

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/bcmills/.cache/go-build"
GOENV="/usr/local/google/home/bcmills/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/usr/local/google/home/bcmills/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/google/home/bcmills"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/google/home/bcmills/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/bcmills/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-e11c94efcb Mon Aug 30 15:39:06 2021 -0400"
GCCGO="/usr/local/google/home/bcmills/bin/gccgo"
AR="ar"
CC="gcc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/usr/local/google/home/bcmills/src/github.com/bcmills/unsafeslice/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2906345833=/tmp/go-build -gno-record-gcc-switches"

What did you do?

In the root of the repository at bcmills/unsafeslice@849066c, run go test ..

What did you expect to see?

A successful test run, or a test failure, or a compile error indicating a problem in my code.

What did you see instead?

panic: interface conversion: types.Object is nil, not *ir.Name

# github.com/bcmills/unsafeslice_test [github.com/bcmills/unsafeslice.test]
panic: interface conversion: types.Object is nil, not *ir.Name

goroutine 1 [running]:
cmd/compile/internal/typecheck.(*importReader).node(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1272 +0x3a5a
cmd/compile/internal/typecheck.(*importReader).expr(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1225 +0x1d
cmd/compile/internal/typecheck.(*importReader).node(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1496 +0x1925
cmd/compile/internal/typecheck.(*importReader).expr(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1225 +0x1d
cmd/compile/internal/typecheck.(*importReader).node(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1464 +0x306f
cmd/compile/internal/typecheck.(*importReader).expr(0x0)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1225 +0x1d
cmd/compile/internal/typecheck.(*importReader).exprList(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1215 +0x47
cmd/compile/internal/typecheck.(*importReader).node(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1496 +0x1945
cmd/compile/internal/typecheck.(*importReader).expr(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1225 +0x1d
cmd/compile/internal/typecheck.(*importReader).node(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1604 +0x1150
cmd/compile/internal/typecheck.(*importReader).stmtList(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1163 +0x5b
cmd/compile/internal/typecheck.(*importReader).node(0xc000886240)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1641 +0x1d12
cmd/compile/internal/typecheck.(*importReader).stmtList(0x8)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1163 +0x5b
cmd/compile/internal/typecheck.(*importReader).funcBody(0xc000886240, 0xc000973340)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1084 +0x92
cmd/compile/internal/typecheck.(*importReader).doInline(0xc79360, 0xc000973340)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:1048 +0x99
cmd/compile/internal/typecheck.ImportBody(0xc000973340)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/typecheck/iimport.go:80 +0x206
cmd/compile/internal/noder.checkFetchBody(0xc000123a00)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:560 +0x96
cmd/compile/internal/noder.(*irgen).getGfInfo(0xc000131000, 0xc000123a00)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:1666 +0x69
cmd/compile/internal/noder.(*irgen).getDictionarySym(0xc000131000, 0xc000123a00, {0xc0004dd020, 0x5be907, 0x1}, 0x10)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:1417 +0x16d
cmd/compile/internal/noder.(*irgen).getDictionarySym(0xc000131000, 0xc000435d40, {0xc0004dcf60, 0x1, 0x1}, 0x1)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:1496 +0x1072
cmd/compile/internal/noder.(*irgen).getDictionaryValue(0xc000901980, 0xc00038b030, {0xc0004dcf60, 0xc00046fa40, 0xc0004dcfb0}, 0xb0)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:1613 +0x25
cmd/compile/internal/noder.(*irgen).getDictOrSubdict(0xc000131000, 0xc000435d40, {0xe68c38, 0xc000148e10}, 0x1, {0xc0004dcf60, 0xc000131000, 0xe69598}, 0x98)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:548 +0x13d
cmd/compile/internal/noder.(*irgen).stencil.func1({0xe68c38, 0xc000148e10})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:110 +0x32c
cmd/compile/internal/ir.Visit.func1({0xe68c38, 0xc000148e10})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/visit.go:105 +0x30
cmd/compile/internal/ir.(*AssignStmt).doChildren(0xc000577ae0, 0xc000599068)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/node_gen.go:152 +0x82
cmd/compile/internal/ir.DoChildren(...)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0xe68850, 0xc000577ae0})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.doNodes({0xc000900480, 0x3, 0x0}, 0xc000599068)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/node_gen.go:1512 +0x67
cmd/compile/internal/ir.(*Func).doChildren(0xe69598, 0xc0008db1e0)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/func.go:152 +0x2e
cmd/compile/internal/ir.DoChildren(...)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0xe69598, 0xc0008db1e0})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.Visit({0xe69598, 0xc0008db1e0}, 0xc000901880)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/ir/visit.go:108 +0xb8
cmd/compile/internal/noder.(*irgen).stencil(0xc000131000)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/stencil.go:91 +0x26a
cmd/compile/internal/noder.(*irgen).generate(0xc000131000, {0xc00000d8a8, 0x3, 0x0})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/irgen.go:294 +0x2d8
cmd/compile/internal/noder.check2({0xc00000d8a8, 0x3, 0x3})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/irgen.go:92 +0x177
cmd/compile/internal/noder.LoadPackage({0xc00001e200, 0x3, 0x0})
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0xd21740)
	/usr/local/google/home/bcmills/go/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
	/usr/local/google/home/bcmills/go/src/cmd/compile/main.go:55 +0xdd
FAIL	github.com/bcmills/unsafeslice [build failed]
FAIL

CC @mdempsky @findleyr @griesemer

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Aug 31, 2021
@bcmills bcmills added this to the Go1.18 milestone Aug 31, 2021
@cuonglm
Copy link
Member

cuonglm commented Aug 31, 2021

It seems to me that https://go-review.googlesource.com/c/go/+/335413 which changed unsafe.Sizeof (and other unsafe functions) to become builtins cause this problem.

@griesemer
Copy link
Contributor

CL 335413 makes unsafe.Sizeof a variable for types that depend on type parameters which is what we need to do if we want to be able to use unsafe.Sizeof in those cases. Not having looked at this issue in detail, there's probably some work in the compiler that needs to be done as well.

@cuonglm
Copy link
Member

cuonglm commented Aug 31, 2021

CL 335413 makes unsafe.Sizeof a variable for types that depend on type parameters which is what we need to do if we want to be able to use unsafe.Sizeof in those cases. Not having looked at this issue in detail, there's probably some work in the compiler that needs to be done as well.

Yeah, I think we need to update the import/export to support this case.

Unified IR is also affected cc @mdempsky

@randall77 randall77 assigned randall77 and unassigned danscales Aug 31, 2021
@gopherbot
Copy link

Change https://golang.org/cl/346469 mentions this issue: cmd/compile: builtins may be in the unsafe package

@gopherbot
Copy link

Change https://golang.org/cl/346769 mentions this issue: cmd/compile: allow objStub from unsafe package

@gopherbot
Copy link

Change https://golang.org/cl/347271 mentions this issue: test: always run test in unified IR mode regardless of explicit -G flag

gopherbot pushed a commit that referenced this issue Sep 2, 2021
CL 346469 added support for unsafe.Sizeof and friends to operate on
generic parameters for compiler importer/exporter. This CL adds support
for unified IR.

Updates #48094

Change-Id: I63af1a7c3478f59b03ecc23229ac2254d3457868
Reviewed-on: https://go-review.googlesource.com/c/go/+/346769
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
gopherbot pushed a commit that referenced this issue Sep 2, 2021
Currently, if a test explicitly specify -G flag, if that flag conflict
with compiler default -G flag, the test will be skipped. That's the
reason CL 346469 haven't fixed the unified IR stuff, but still make the
unified builder passed.

This CL makes run.go always run the test in unified IR mode, regardless
of the explicit -G flag specified.

Updates #48094

Change-Id: I959ecaff6aca07844f0ffcf36caa60cf0747e8ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/347271
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@gopherbot
Copy link

Change https://golang.org/cl/347529 mentions this issue: cmd/compile: fix unified IR panic when expanding nested inline function

gopherbot pushed a commit that referenced this issue Sep 9, 2021
When reading body of inlining function, which has another inlined
function in the body, the reader still add this inlined function to
todoBodies, which it shouldn't because the inlined function was read
already.

To fix this, introduce new flag to signal that we are done construting
all functions in todoBodies, thus the addBody shouldn't add anything
to todoBodies then.

Updates #48094

Change-Id: I45105dd518f0a7b69c6dcbaf23b957623f271203
Reviewed-on: https://go-review.googlesource.com/c/go/+/347529
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

6 participants