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

@v0.3.3/go/ir: []byte to [4]byte conversion in net/netip package causes builder panic #1343

Closed
adonovan opened this issue Dec 18, 2022 · 2 comments

Comments

@adonovan
Copy link
Contributor

adonovan commented Dec 18, 2022

The IR builder appears to lack support for the new slice-to-array (not pointer-to-array) conversions supported in the upcoming go1.20 and already used in the standard library, such as in the net/netip package. This causes it to panic.

(@taking has spent a lot of effort thinking about this logic in x/tools/go/ssa so you may want to confer with him.)

Typical panic:
https://storage.googleapis.com/go-build-log/8bcc4906/linux-amd64-boringcrypto_ad40fb56.log

panic: in net/netip.AddrFromSlice: cannot convert Load <[]byte> t0 ([]byte) to [4]byte

goroutine 18344 [running]:
honnef.co/go/tools/go/ir.emitConv(0xc0203aaf00, {0x1350358, 0xc0210a07e0}, {0x13469a0?, 0xc01f2c3a10}, {0x13460b8, 0xc013b3b740})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/emit.go:293 +0xd29
honnef.co/go/tools/go/ir.(*builder).expr0(0xc01cfaf930, 0xc0203aaf00, {0x1348f90?, 0xc013b3b740?}, {0x7, {0x13469a0, 0xc01f2c3a10}, {0x0, 0x0}})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:610 +0x5d7
honnef.co/go/tools/go/ir.(*builder).expr(0x1346ae0?, 0xc0203aaf00, {0x1348f90, 0xc013b3b740})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:566 +0x1fa
honnef.co/go/tools/go/ir.(*builder).emitCallArgs(0x1346ae0?, 0xc0203aaf00, 0xc0153041c0, 0xc013b3b7c0, {0x0?, 0x0, 0x58a2e7?})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:975 +0x135
honnef.co/go/tools/go/ir.(*builder).setCall(0xf99960?, 0xc0203aaf00, 0xc013b3b7c0, 0xc020b3f088)
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:1037 +0x8e
honnef.co/go/tools/go/ir.(*builder).expr0(0xc01cfaf930, 0xc0203aaf00, {0x1348f90?, 0xc013b3b7c0?}, {0x7, {0x1346a68, 0xc01d7fad20}, {0x0, 0x0}})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:623 +0x218e
honnef.co/go/tools/go/ir.(*builder).expr(0xc01cfaed80?, 0xc0203aaf00, {0x1348f90, 0xc013b3b7c0})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:566 +0x1fa
honnef.co/go/tools/go/ir.(*builder).stmt(0xc0203aaf00?, 0xc0203aaf00, {0x13494d0?, 0xc01df1d2e0?})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2291 +0x194c
honnef.co/go/tools/go/ir.(*builder).stmtList(...)
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:855
honnef.co/go/tools/go/ir.(*builder).switchStmt(0xc01cfaf210?, 0xc0203aaf00, 0xc01df1b0e0, 0x0)
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:1366 +0x19a5
honnef.co/go/tools/go/ir.(*builder).stmt(0x20?, 0xc0203aaf00, {0x1349620?, 0xc01df1b0e0?})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2365 +0x121c
honnef.co/go/tools/go/ir.(*builder).stmtList(0x5909c5?, 0xc01cfaf400?, {0xc01df1d4a0?, 0x2, 0x5922f0?})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:855 +0x45
honnef.co/go/tools/go/ir.(*builder).stmt(0xc0203aaf00?, 0xc0203aaf00, {0x1348f30?, 0xc01df1b110?})
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2338 +0x9b9
honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc01cfaf930, 0xc0203aaf00)
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2450 +0x3d7
honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0x0?, 0xc020388480, 0xc01df1b140)
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2488 +0x19b
honnef.co/go/tools/go/ir.(*Package).build(0xc020388480)
	/workdir/gopath/pkg/mod/honnef.co/go/tools@v0.3.3/go/ir/builder.go:2594 +0xc16
@adonovan adonovan added bug needs-triage Newly filed issue that needs triage labels Dec 18, 2022
@adonovan adonovan changed the title honnef.co/go/tools@v0.3.3/go/ir: []byte to [4]byte conversion in net/netip package causes builder panic @v0.3.3/go/ir: []byte to [4]byte conversion in net/netip package causes builder panic Dec 18, 2022
@dominikh dominikh added duplicate and removed needs-triage Newly filed issue that needs triage labels Dec 18, 2022
@dominikh
Copy link
Owner

This is already fixed on the master branch (as of 39b8ce7). It'll be part of the next release, which is planned to release shortly after Go 1.20 does.

Generally speaking. the latest release of Staticcheck supports the latest release of Go (and the one before that), and the upcoming release of Go is supported by the master branch.

@adonovan
Copy link
Contributor Author

adonovan commented Dec 18, 2022

Aha, I used @latest and of course didn't get the fix but I should have suspected you'd already fixed it on the master branch. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants