copygen
copygen copied to clipboard
fix: Panic running against Go 1.22
What
When running copygen 0.4.0 using Go 1.22, a panic is encountered. This due to the old version of golang.org/x/tools on which this tool currently depends.
This issue was fixed in the tools library here: https://github.com/golang/go/issues/62167
How
go get golang.org/x/[email protected]
Panic
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=0x2 addr=0x0 pc=0x1047087b4]
goroutine 267 [running]:
go/types.(*Checker).handleBailout(0x1400053c800, 0x140007f7c38)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:367 +0x9c
panic({0x104f22e80?, 0x105586360?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x105019b00, 0x105592880})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/sizes.go:333
go/types.representableConst.func1({0x105019b00?, 0x105592880?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x10501dfe0, 0x105564760}, 0x1400053c800, 0x105592880, 0x140007f6038)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x1400053c800, 0x140005b11c0, 0x105592880)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x1400053c800, 0x140005b11c0, {0x105019b00, 0x105592880})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:375 +0x304
go/types.(*Checker).convertUntyped(0x1400053c800, 0x140005b11c0, {0x105019b00, 0x105592880})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:289 +0x30
go/types.(*Checker).matchTypes(0x1400053c800, 0x140005b1180, 0x140005b11c0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:926 +0x7c
go/types.(*Checker).binary(0x1400053c800, 0x140005b1180, {0x10501c200, 0x140004e2ae0}, {0x10501bf60, 0x140005141a0}, {0x10501c710, 0x140005141c0}, 0x28, 0x35853)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:800 +0x114
go/types.(*Checker).exprInternal(0x1400053c800, 0x0, 0x140005b1180, {0x10501c200, 0x140004e2ae0}, {0x0, 0x0})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x1400053c800, 0x0, 0x140005b1180, {0x10501c200?, 0x140004e2ae0?}, {0x0?, 0x0?}, 0x0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x1400053c800, 0x10501a208?, 0x140005b1180, {0x10501c200?, 0x140004e2ae0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).stmt(0x1400053c800, 0x0, {0x10501c560, 0x140007387c0})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:570 +0xda4
go/types.(*Checker).stmtList(0x1400053c800, 0x0, {0x14000514320?, 0x0?, 0x0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:121 +0x88
go/types.(*Checker).funcBody(0x1400053c800, 0x105019b00?, {0x1400060c0d8?, 0x105592a60?}, 0x140005b0ec0, 0x140004e2b70, {0x0?, 0x0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:41 +0x21c
go/types.(*Checker).funcDecl.func1()
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/decl.go:852 +0x44
go/types.(*Checker).processDelayed(0x1400053c800, 0x0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:467 +0x12c
go/types.(*Checker).checkFiles(0x1400053c800, {0x140000c2008, 0x1, 0x1})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:411 +0x188
go/types.(*Checker).Files(...)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0x140001f02a0, 0x14000327ce0)
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:966 +0x624
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:803 +0x178
sync.(*Once).doSlow(0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/sync/once.go:74 +0x100
sync.(*Once).Do(...)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:791 +0x50
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:798 +0x30
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 262
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:797 +0x84
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=0x2 addr=0x0 pc=0x1047087b4]
goroutine 81 [running]:
go/types.(*Checker).handleBailout(0x140006c8200, 0x140006e3c38)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:367 +0x9c
panic({0x104f22e80?, 0x105586360?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x105019b00, 0x105592920})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/sizes.go:228 +0x314
go/types.(*Config).sizeof(...)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/sizes.go:333
go/types.representableConst.func1({0x105019b00?, 0x105592920?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x10501dfe0, 0x1055647b0}, 0x140006c8200, 0x105592920, 0x140006dee58)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:106 +0x2b0
go/types.(*Checker).representation(0x140006c8200, 0x14000738ec0, 0x105592920)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:256 +0x68
go/types.(*Checker).representable(0x140006c8200, 0x14000738ec0, 0x105592920)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/const.go:239 +0x28
go/types.(*Checker).shift(0x140006c8200, 0x14000738e00, 0x14000738ec0, {0x10501c200, 0x140006b4360}, 0x14)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:650 +0x1d8
go/types.(*Checker).binary(0x140006c8200, 0x14000738e00, {0x10501c200, 0x140006b4360}, {0x10501bfc0, 0x140006a45e0}, {0x10501c710, 0x140006a4600}, 0x14, 0x1032)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:796 +0x100
go/types.(*Checker).exprInternal(0x140006c8200, 0x0, 0x14000738e00, {0x10501c200, 0x140006b4360}, {0x0, 0x0})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x140006c8200, 0x0, 0x14000738e00, {0x10501c200?, 0x140006b4360?}, {0x0?, 0x0?}, 0x0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140006c8200, 0x1046fce00?, 0x14000738e00, {0x10501c200?, 0x140006b4360?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).binary(0x140006c8200, 0x14000738e00, {0x10501c200, 0x140006b43c0}, {0x10501c200, 0x140006b4360}, {0x10501bfc0, 0x140006a4660}, 0x12, 0x1037)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:783 +0x70
go/types.(*Checker).exprInternal(0x140006c8200, 0x0, 0x14000738e00, {0x10501c200, 0x140006b43c0}, {0x0, 0x0})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x140006c8200, 0x0, 0x14000738e00, {0x10501c200?, 0x140006b43c0?}, {0x0?, 0x0?}, 0x0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140006c8200, 0x1047194b0?, 0x14000738e00, {0x10501c200?, 0x140006b43c0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).binary(0x140006c8200, 0x14000738e00, {0x10501c200, 0x140006b43f0}, {0x10501c200, 0x140006b43c0}, {0x10501bf60, 0x140006a4680}, 0xc, 0x1046)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:783 +0x70
go/types.(*Checker).exprInternal(0x140006c8200, 0x0, 0x14000738e00, {0x10501c200, 0x140006b43f0}, {0x0, 0x0})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x140006c8200, 0x0, 0x14000738e00, {0x10501c200?, 0x140006b43f0?}, {0x0?, 0x0?}, 0x0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140006c8200, 0x105592ba0?, 0x14000738e00, {0x10501c200?, 0x140006b43f0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).initVars(0x140006c8200, {0x140004f0030, 0x1, 0x1046dee34?}, {0x1400068a160, 0x14000738d80?, 0x105019b00?}, {0x10501c4a0, 0x140006a46a0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/assignments.go:381 +0x570
go/types.(*Checker).stmt(0x140006c8200, 0x0, {0x10501c4a0, 0x140006a46a0})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:524 +0x1898
go/types.(*Checker).stmtList(0x140006c8200, 0x0, {0x1400068a170?, 0x104c97f78?, 0x5?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:121 +0x88
go/types.(*Checker).stmt(0x140006c8200, 0x0, {0x10501c530, 0x140006b4420})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:562 +0x1974
go/types.(*Checker).stmt(0x140006c8200, 0x0, {0x10501c560, 0x140006b2240})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:574 +0x258c
go/types.(*Checker).stmtList(0x140006c8200, 0x0, {0x140006a4700?, 0x0?, 0x0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:121 +0x88
go/types.(*Checker).funcBody(0x140006c8200, 0x105019b00?, {0x140006880f0?, 0x105592ba0?}, 0x140003d6680, 0x140006b4450, {0x0?, 0x0?})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/stmt.go:41 +0x21c
go/types.(*Checker).funcDecl.func1()
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/decl.go:852 +0x44
go/types.(*Checker).processDelayed(0x140006c8200, 0x0)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:467 +0x12c
go/types.(*Checker).checkFiles(0x140006c8200, {0x14000076040, 0x1, 0x1})
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:411 +0x188
go/types.(*Checker).Files(...)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0x140001f02a0, 0x14000424460)
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:966 +0x624
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:803 +0x178
sync.(*Once).doSlow(0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/sync/once.go:74 +0x100
sync.(*Once).Do(...)
/opt/homebrew/Cellar/go/1.22.1/libexec/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:791 +0x50
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:798 +0x30
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 49
/Users/ME/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:797 +0x84
just ran into this too