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,go/types}: crash in variadic call #70526

Open
adonovan opened this issue Nov 22, 2024 · 1 comment
Open

{cmd/compile,go/types}: crash in variadic call #70526

adonovan opened this issue Nov 22, 2024 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Nov 22, 2024

This program crashes the type checker:

package a

var x int

func f(...any)

var _ = f(0, x...)

both in the compiler:

~$ cd w/goroot/src

src$ git log -1 | grep commit
commit 5050e37dbf723e3689721519eddb704dfdd7148e
src$ cat  ../../xtools/a.go
package a

var x int

func f(...any)

var _ = f(0, x...)

src$ go tool compile   ../../xtools/a.go
<unknown line number>: internal compiler error: panic: interface conversion: syntax.Type is *types2.Basic, not *types2.Slice

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/adonovan/w/goroot/src/runtime/debug/stack.go:26 +0x64
cmd/compile/internal/base.FatalfAt({0x341a8?, 0x140?}, {0x100c583d9, 0x9}, {0x140000341d8, 0x1, 0x1})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/base/print.go:230 +0x20c
cmd/compile/internal/base.Fatalf(...)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/base/print.go:195
cmd/compile/internal/gc.handlePanic()
	/Users/adonovan/w/goroot/src/cmd/compile/internal/gc/main.go:54 +0x8c
panic({0x100e48660?, 0x140003c67b0?})
	/Users/adonovan/w/goroot/src/runtime/panic.go:787 +0x124
cmd/compile/internal/types2.(*Checker).handleBailout(0x14000003880, 0x140000351f8)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/check.go:396 +0x98
panic({0x100e48660?, 0x140003c67b0?})
	/Users/adonovan/w/goroot/src/runtime/panic.go:787 +0x124
cmd/compile/internal/types2.(*Checker).typesSummary(0x14000003880, {0x1400001f480?, 0x2, 0x100c6ebb1?}, 0x1)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/assignments.go:320 +0x3ac
cmd/compile/internal/types2.(*Checker).arguments(0x14000003880, 0x14000138b60, 0x140003f8dc0, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x14000030aa0, ...}, ...)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/call.go:533 +0x1294
cmd/compile/internal/types2.(*Checker).callExpr(0x14000003880, 0x140003f8e80, 0x14000138b60)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/call.go:296 +0x464
cmd/compile/internal/types2.(*Checker).exprInternal(0x14000003880, 0x0, 0x140003f8e80, {0x100edfdd8, 0x14000138b60}, {0x0?, 0x0?})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/expr.go:1104 +0x204
cmd/compile/internal/types2.(*Checker).rawExpr(0x14000003880, 0x0, 0x140003f8e80, {0x100edfdd8?, 0x14000138b60?}, {0x0?, 0x0?}, 0x0)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/expr.go:959 +0x128
cmd/compile/internal/types2.(*Checker).expr(0x14000003880, 0x0?, 0x140003f8e80, {0x100edfdd8?, 0x14000138b60?})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/expr.go:1275 +0x38
cmd/compile/internal/types2.(*Checker).varDecl(0x14000003880, 0x14000138f50, {0x14000062700, 0x1, 0x1}, {0x0, 0x0}, {0x100edfdd8, 0x14000138b60})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/decl.go:431 +0x13c
cmd/compile/internal/types2.(*Checker).objDecl(0x14000003880, {0x100ee45a0, 0x14000138f50}, 0x0)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/decl.go:186 +0x818
cmd/compile/internal/types2.(*Checker).packageObjects(...)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/resolver.go:695
cmd/compile/internal/types2.(*Checker).checkFiles(0x14000003880, {0x140000626d8?, 0x1014fe920?, 0x14000003880?})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/check.go:451 +0x694
cmd/compile/internal/types2.(*Checker).Files(0x100ec6fc0?, {0x140000626d8?, 0x0?, 0x0?})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/check.go:414 +0x80
cmd/compile/internal/types2.(*Config).Check(0x14000138bd0, {0x100c5d6d0?, 0x1400000e077?}, {0x140000626d8, 0x1, 0x1}, 0x140003fc5a0)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/types2/api.go:480 +0x134
cmd/compile/internal/noder.checkFiles({0x0, {0x0, 0x0}}, {0x140000626a8, 0x1, 0x14000035488?})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/noder/irgen.go:95 +0x4b4
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0x140000626a8, 0x1, 0x1})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/noder/unified.go:319 +0x48
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0x140000626a8?, 0x100e0acc0?, 0x0?})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/noder/unified.go:195 +0xb4
cmd/compile/internal/noder.LoadPackage({0x1400001e130, 0x1, 0x1})
	/Users/adonovan/w/goroot/src/cmd/compile/internal/noder/noder.go:77 +0x398
cmd/compile/internal/gc.Main(0x100ed4220)
	/Users/adonovan/w/goroot/src/cmd/compile/internal/gc/main.go:208 +0xc10
main.main()
	/Users/adonovan/w/goroot/src/cmd/compile/main.go:57 +0x110
src$ 

and go/types, here demonstrated via gopls:

xtools$ go version
go version devel go1.24-a86ea80197 Thu Nov 21 19:44:18 2024 +0000 darwin/arm64

xtools$ git log -1 | head -n 1
commit 1e0d4ee6a4771f70b0f2625329c97b4103b69d09

xtools$ cat a.go 
package a

var x int

func f(...any)

var _ = f(0, x...)

xtools$ go run ./gopls check a.go
panic: interface conversion: types.Type is *types.Basic, not *types.Slice [recovered]
	panic: interface conversion: types.Type is *types.Basic, not *types.Slice

goroutine 3271 gp=0x14000502540 m=8 mp=0x14000580008 [running]:
panic({0x1057938a0?, 0x1400ac92b70?})
	/Users/adonovan/w/goroot/src/runtime/panic.go:806 +0x154 fp=0x140081407d0 sp=0x14008140720 pc=0x104a82584
go/types.(*Checker).handleBailout(0x14000102e00, 0x140081417c8)
	/Users/adonovan/w/goroot/src/go/types/check.go:421 +0x98 fp=0x140081407f0 sp=0x140081407d0 pc=0x104de1918
go/types.(*Checker).Files.deferwrap1()
	/Users/adonovan/w/goroot/src/go/types/check.go:438 +0x2c fp=0x14008140810 sp=0x140081407f0 pc=0x104de1a3c
panic({0x1057938a0?, 0x1400ac92b70?})
	/Users/adonovan/w/goroot/src/runtime/panic.go:787 +0x124 fp=0x140081408c0 sp=0x14008140810 pc=0x104a82554
runtime.panicdottypeE(...)
	/Users/adonovan/w/goroot/src/runtime/iface.go:275
runtime.panicdottypeI(0x1058e7568?, 0x1057c5c20, 0x1057a6680)
	/Users/adonovan/w/goroot/src/runtime/iface.go:285 +0x70 fp=0x140081408f0 sp=0x140081408c0 pc=0x104a1ffa0
go/types.(*Checker).typesSummary(0x14000102e00, {0x1400a76cac0?, 0x2, 0x14008140d20?}, 0x1)
	/Users/adonovan/w/goroot/src/go/types/assignments.go:323 +0x3ac fp=0x140081409a0 sp=0x140081408f0 pc=0x104dd342c
go/types.(*Checker).arguments(0x14000102e00, 0x1400ac90780, 0x1400ac90940, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1400a76e760, ...}, ...)
	/Users/adonovan/w/goroot/src/go/types/call.go:533 +0x162c fp=0x14008140db0 sp=0x140081409a0 pc=0x104ddeefc
go/types.(*Checker).callExpr(0x14000102e00, 0x1400ac90a00, 0x1400ac90780)
	/Users/adonovan/w/goroot/src/go/types/call.go:298 +0x5bc fp=0x140081410a0 sp=0x14008140db0 pc=0x104ddc0ec
go/types.(*Checker).exprInternal(0x14000102e00, 0x104a2311c?, 0x1400ac90a00, {0x1058ebc60, 0x1400ac90780}, {0x0?, 0x0?})
	/Users/adonovan/w/goroot/src/go/types/expr.go:1088 +0x19c fp=0x140081411d0 sp=0x140081410a0 pc=0x104df24dc
go/types.(*Checker).rawExpr(0x14000102e00, 0x0, 0x1400ac90a00, {0x1058ebc60?, 0x1400ac90780?}, {0x0?, 0x0?}, 0x0)
	/Users/adonovan/w/goroot/src/go/types/expr.go:952 +0x120 fp=0x14008141270 sp=0x140081411d0 pc=0x104df1f10
go/types.(*Checker).expr(0x14000102e00, 0x0?, 0x1400ac90a00, {0x1058ebc60?, 0x1400ac90780?})
	/Users/adonovan/w/goroot/src/go/types/expr.go:1227 +0x38 fp=0x140081412c0 sp=0x14008141270 pc=0x104df3768
go/types.(*Checker).varDecl(0x14000102e00, 0x1400ac8e660, {0x1400011d828, 0x1, 0x1}, {0x0, 0x0}, {0x1058ebc60, 0x1400ac90780})
	/Users/adonovan/w/goroot/src/go/types/decl.go:506 +0x13c fp=0x14008141330 sp=0x140081412c0 pc=0x104de925c
go/types.(*Checker).objDecl(0x14000102e00, {0x1058fac38, 0x1400ac8e660}, 0x0)
	/Users/adonovan/w/goroot/src/go/types/decl.go:187 +0x7dc fp=0x14008141560 sp=0x14008141330 pc=0x104de6a6c
go/types.(*Checker).packageObjects(0x14000102e00)
	/Users/adonovan/w/goroot/src/go/types/resolver.go:690 +0x404 fp=0x140081416a0 sp=0x14008141560 pc=0x104e15374
go/types.(*Checker).checkFiles(0x14000102e00, {0x1400011d800?, 0x8?, 0x105798d20?})
	/Users/adonovan/w/goroot/src/go/types/check.go:476 +0x2b0 fp=0x14008141790 sp=0x140081416a0 pc=0x104de1d20
go/types.(*Checker).Files(0x0?, {0x1400011d800?, 0x1400ac8e2a0?, 0x1400ac96000?})
	/Users/adonovan/w/goroot/src/go/types/check.go:439 +0x80 fp=0x14008141800 sp=0x14008141790 pc=0x104de19b0
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0x1400ac90380, {0x1058ed058, 0x1400a771f20}, 0x1400ac90340, 0x1400ac94000, 0x1400ac923f0)
	/Users/adonovan/w/xtools/gopls/internal/cache/check.go:1543 +0x730 fp=0x14008141b90 sp=0x14008141800 pc=0x1051a3ed0
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getPackage.func1({0x1058ed058, 0x1400a771f20})
	/Users/adonovan/w/xtools/gopls/internal/cache/check.go:420 +0x2c0 fp=0x14008141d10 sp=0x14008141b90 pc=0x10519d460
golang.org/x/tools/gopls/internal/cache.(*futureCache[...]).get(0x1058eb260, {0x1058ed058, 0x1400a771f20}, {0x14000037a70, 0x12}, 0x140000b1e70)
	/Users/adonovan/w/xtools/gopls/internal/cache/future.go:126 +0x360 fp=0x14008141e30 sp=0x14008141d10 pc=0x1051de400
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).getPackage(0x1058ed001?, {0x1058ed058?, 0x1400a771f20?}, 0x10519cce4?)
	/Users/adonovan/w/xtools/gopls/internal/cache/check.go:371 +0x5c fp=0x14008141e90 sp=0x14008141e30 pc=0x10519d16c
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0x1400ac90380, {0x1058ed058, 0x1400a771f20}, 0x0, {0x14000037a70?, 0x0?}, 0x1400ac92360, 0x1400ac90540)
	/Users/adonovan/w/xtools/gopls/internal/cache/check.go:360 +0x88 fp=0x14008141ed0 sp=0x14008141e90 pc=0x10519d058
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).query.func1()
	/Users/adonovan/w/xtools/gopls/internal/cache/check.go:298 +0xa8 fp=0x14008141f60 sp=0x14008141ed0 pc=0x10519cd28
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/Users/adonovan/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x54 fp=0x14008141fd0 sp=0x14008141f60 pc=0x104b44554
runtime.goexit({})
	/Users/adonovan/w/goroot/src/runtime/asm_arm64.s:1260 +0x4 fp=0x14008141fd0 sp=0x14008141fd0 pc=0x104a8ab94
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 3269
	/Users/adonovan/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x94

etc
@adonovan adonovan added the gopls Issues related to the Go language server, gopls. label Nov 22, 2024
@adonovan adonovan added this to the gopls/v0.17.0 milestone Nov 22, 2024
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 22, 2024
@adonovan adonovan changed the title x/tools/gopls: crashes in type checker {cmd/compile,go/types}: crash in variadic call Nov 22, 2024
@adonovan adonovan added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 22, 2024
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. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants