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

Update x/tools to fix panic in tests with Go 1.23 #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexandear
Copy link

@alexandear alexandear commented Nov 20, 2024

This PR fixes panic in tests when running with Go 1.23.

golang.org/x/tools requires go 1.18 in go.mod.

Details

❯ go version
go version go1.23.3 darwin/arm64
❯ go test ./...
?       4d63.com/gochecknoglobals       [no test files]
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=0x1010eea94]

goroutine 162 [running]:
go/types.(*Checker).handleBailout(0x1400007a380, 0x140005bbc08)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/check.go:404 +0x9c
panic({0x101202500?, 0x1013e4620?})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/runtime/panic.go:785 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x10124fe48, 0x1013e7b60})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/sizes.go:229 +0x314
go/types.(*Config).sizeof(...)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/sizes.go:334
go/types.representableConst.func1({0x10124fe48?, 0x1013e7b60?})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/const.go:77 +0x90
go/types.representableConst({0x101251588, 0x1013dbd40}, 0x1400007a380, 0x1013e7b60, 0x140005baa28)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/const.go:93 +0x134
go/types.(*Checker).representation(0x1400007a380, 0x14000011140, 0x1013e7b60)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/const.go:257 +0x68
go/types.(*Checker).implicitTypeAndValue(0x1400007a380, 0x14000011140, {0x10124fe48, 0x1013e7b60})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/expr.go:377 +0x304
go/types.(*Checker).convertUntyped(0x1400007a380, 0x14000011140, {0x10124fe48, 0x1013e7b60})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/const.go:290 +0x30
go/types.(*Checker).matchTypes(0x1400007a380, 0x14000011100, 0x14000011140)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/expr.go:928 +0x7c
go/types.(*Checker).binary(0x1400007a380, 0x14000011100, {0x101250a18, 0x1400019c6c0}, {0x1012505f8, 0x1400028a2c0}, {0x1012506b8, 0x1400028a2e0}, 0x28, 0x3a361)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/expr.go:802 +0x114
go/types.(*Checker).exprInternal(0x1400007a380, 0x0, 0x14000011100, {0x101250a18, 0x1400019c6c0}, {0x0, 0x0})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/expr.go:1452 +0x1d4
go/types.(*Checker).rawExpr(0x1400007a380, 0x0, 0x14000011100, {0x101250a18?, 0x1400019c6c0?}, {0x0?, 0x0?}, 0x0)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/expr.go:981 +0x120
go/types.(*Checker).expr(0x1400007a380, 0x10124fc40?, 0x14000011100, {0x101250a18?, 0x1400019c6c0?})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/expr.go:1549 +0x38
go/types.(*Checker).stmt(0x1400007a380, 0x0, {0x101250d78, 0x140000103c0})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/stmt.go:579 +0xa3c
go/types.(*Checker).stmtList(0x1400007a380, 0x0, {0x1400028a440?, 0x1400007a380?, 0x3?})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/stmt.go:121 +0x88
go/types.(*Checker).funcBody(0x1400007a380, 0x1012505f8?, {0x1400000e2c0?, 0x101253b58?}, 0x14000010e40, 0x1400019c8d0, {0x0?, 0x0?})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/stmt.go:41 +0x218
go/types.(*Checker).funcDecl.func1()
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/decl.go:888 +0x44
go/types.(*Checker).processDelayed(0x1400007a380, 0x0)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/check.go:516 +0x12c
go/types.(*Checker).checkFiles(0x1400007a380, {0x14000114800, 0x1, 0x1})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/check.go:462 +0x1b4
go/types.(*Checker).Files(0x1400018e2a0?, {0x14000114800?, 0x1400012dd40?, 0x6?})
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/go/types/check.go:422 +0x80
golang.org/x/tools/go/packages.(*loader).loadPackage(0x1400018e2a0, 0x140000a7cb0)
        /Users/Oleksandr_Redko/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:1044 +0x76c
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /Users/Oleksandr_Redko/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:851 +0x178
sync.(*Once).doSlow(0x0?, 0x0?)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:76 +0xf8
sync.(*Once).Do(...)
        /opt/homebrew/Cellar/go/1.23.3/libexec/src/sync/once.go:67
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        /Users/Oleksandr_Redko/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:839 +0x48
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
        /Users/Oleksandr_Redko/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:846 +0x30
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 29
        /Users/Oleksandr_Redko/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:845 +0x84
FAIL    4d63.com/gochecknoglobals/checknoglobals        0.585s
FAIL

@StevenACoffman
Copy link

@leighmcculloch Can you merge this PR? I came to contribute the same fix so I can use your linter again.

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

Successfully merging this pull request may close these issues.

2 participants