-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
Problem statement
Go 1.22 just got released and the pipeline of Forgejo started panicking when running with this version of Go:
go run github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 generate spec -x "code.gitea.io/sdk" -o './templates/swagger/v1_json.tmpl'
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe1fc1e]
goroutine 689 [running]:
go/types.(*Checker).handleBailout(0xc00053e000, 0xc00134dbd0)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/check.go:367 +0x88
panic({0x112b140?, 0x19adfa0?})
/opt/hostedtoolcache/go/1.22.0/x64/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0x1403fc0, 0x19b8e40})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/sizes.go:228 +0x31e
go/types.(*Config).sizeof(...)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/sizes.go:333
go/types.representableConst.func1({0x1403fc0?, 0x19b8e40?})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/const.go:76 +0x9e
go/types.representableConst({0x1408dc0, 0x19eb720}, 0xc00053e000, 0x19b8e40, 0xc00134bfe8)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc00053e000, 0xc000b95480, 0x19b8e40)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/const.go:256 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc00053e000, 0xc000b95480, {0x1403fc0, 0x19b8e40})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/expr.go:375 +0x30d
go/types.(*Checker).convertUntyped(0xc00053e000, 0xc000b95480, {0x1403fc0, 0x19b8e40})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/const.go:289 +0x3f
go/types.(*Checker).matchTypes(0xc00053e000, 0xc000b95440, 0xc000b95480)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/expr.go:926 +0x79
go/types.(*Checker).binary(0xc00053e000, 0xc000b95440, {0x14075e8, 0xc0013b60f0}, {0x1406778, 0xc000b92100}, {0x14068c8, 0xc000b92180}, 0x28, 0x76f8)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/expr.go:800 +0x166
go/types.(*Checker).exprInternal(0xc00053e000, 0x0, 0xc000b95440, {0x14075e8, 0xc0013b60f0}, {0x0, 0x0})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/expr.go:1416 +0x206
go/types.(*Checker).rawExpr(0xc00053e000, 0x0, 0xc000b95440, {0x14075e8?, 0xc0013b60f0?}, {0x0?, 0x0?}, 0x0)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/expr.go:979 +0x19e
go/types.(*Checker).expr(0xc00053e000, 0x1404c90?, 0xc000b95440, {0x14075e8?, 0xc0013b60f0?})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/expr.go:1513 +0x30
go/types.(*Checker).stmt(0xc00053e000, 0x0, {0x1407948, 0xc000b94140})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/stmt.go:570 +0x11f2
go/types.(*Checker).stmtList(0xc00053e000, 0x0, {0xc000b92400?, 0x0?, 0x0?})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/stmt.go:121 +0x85
go/types.(*Checker).funcBody(0xc00053e000, 0x1403fc0?, {0xc0013980b8?, 0x19b9020?}, 0xc000b95080, 0xc0013b6180, {0x0?, 0x0?})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/stmt.go:41 +0x331
go/types.(*Checker).funcDecl.func1()
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/decl.go:852 +0x3a
go/types.(*Checker).processDelayed(0xc00053e000, 0x0)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/check.go:467 +0x162
go/types.(*Checker).checkFiles(0xc00053e000, {0xc0013b8000, 0x1, 0x1})
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/check.go:411 +0x1cc
go/types.(*Checker).Files(...)
/opt/hostedtoolcache/go/1.22.0/x64/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc0001888c0, 0xc0008ff620)
/root/go/pkg/mod/golang.org/x/tools@v0.9.3/go/packages/packages.go:1055 +0xa72
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
/root/go/pkg/mod/golang.org/x/tools@v0.9.3/go/packages/packages.go:854 +0x1a9
sync.(*Once).doSlow(0x0?, 0x0?)
/opt/hostedtoolcache/go/1.22.0/x64/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
/opt/hostedtoolcache/go/1.22.0/x64/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
/root/go/pkg/mod/golang.org/x/tools@v0.9.3/go/packages/packages.go:842 +0x4a
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
/root/go/pkg/mod/golang.org/x/tools@v0.9.3/go/packages/packages.go:849 +0x26
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 680
/root/go/pkg/mod/golang.org/x/tools@v0.9.3/go/packages/packages.go:848 +0x94
exit status 2
I suspect the outdated version of golang.org/x/tools
(v0.9.3) to be the culprit.
Running this with the latest version went fine: github.com/go-swagger/go-swagger/cmd/swagger@v0.30.6-0.20240201115257-bcc7c78b7786
(its go.mod file uses golang.org/x/tools v0.17.0).
Environment
swagger version: 0.30.5 (latest tagged)
go version: 1.22.0
OS: linux (inside docker)
Suggested solution
Add a tag with a version of golang.org/x/tools recent enough to run with Go 1.22.
Rmaan, wolfmetr, trdyer, simondeziel, SebastiaanPasterkamp and 16 morexqbumu, agilgur5, silverwind and alexstojda