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

Fix: Update golang.org/x/tools dependency to support Go v1.22.0 #401

Merged
merged 4 commits into from
Feb 7, 2024

Conversation

toddtreece
Copy link
Contributor

@toddtreece toddtreece commented Feb 7, 2024

What

  • Fixes Crashing with Go 1.22 #400 by upgrading golang.org/x/tools
  • gofmt fixes suggested by internal/runtests.sh
  • alldeps updates suggested by internal/runtests.sh

Why

I encountered this error during wire generation when trying to build Grafana with Go v1.22.0:

/home/todd/go/bin/wire-v0.5.0 gen -tags "oss" ./pkg/server
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=0x5805de]

goroutine 1555 [running]:
go/types.(*Checker).handleBailout(0xc004732000, 0xc00760dca8)
        /usr/local/go/src/go/types/check.go:367 +0x88
panic({0x680d60?, 0x88d3a0?})
        /usr/local/go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0x7250d8, 0x891800})
        /usr/local/go/src/go/types/sizes.go:228 +0x31e
go/types.(*Config).sizeof(...)
        /usr/local/go/src/go/types/sizes.go:333
go/types.representableConst.func1({0x7250d8?, 0x891800?})
        /usr/local/go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0x726af8, 0x885d78}, 0xc004732000, 0x891800, 0xc00760bdb8)
        /usr/local/go/src/go/types/const.go:106 +0x2c7
go/types.(*Checker).representation(0xc004732000, 0xc004ace2c0, 0x891800)
        /usr/local/go/src/go/types/const.go:256 +0x65
go/types.(*Checker).representable(0xc004732000, 0xc004ace2c0, 0x891800)
        /usr/local/go/src/go/types/const.go:239 +0x26
go/types.(*Checker).shift(0xc004732000, 0xc004ace1c0, 0xc004ace2c0, {0x725d60, 0xc0073cea20}, 0x14)
        /usr/local/go/src/go/types/expr.go:650 +0x1eb
go/types.(*Checker).binary(0xc004732000, 0xc004ace1c0, {0x725d60, 0xc0073cea20}, {0x726330, 0xc004dec8c0}, {0x726330, 0xc004dec8e0}, 0x14, 0x3803)
        /usr/local/go/src/go/types/expr.go:796 +0x150
go/types.(*Checker).exprInternal(0xc004732000, 0x0, 0xc004ace1c0, {0x725d60, 0xc0073cea20}, {0x0, 0x0})
        /usr/local/go/src/go/types/expr.go:1416 +0x206
go/types.(*Checker).rawExpr(0xc004732000, 0x0, 0xc004ace1c0, {0x725d60?, 0xc0073cea20?}, {0x0?, 0x0?}, 0x0)
        /usr/local/go/src/go/types/expr.go:979 +0x19e
go/types.(*Checker).expr(0xc004732000, 0x0?, 0xc004ace1c0, {0x725d60?, 0xc0073cea20?})
        /usr/local/go/src/go/types/expr.go:1513 +0x30
go/types.(*Checker).binary(0xc004732000, 0xc004ace1c0, {0x725d60, 0xc0073cea50}, {0x725d60, 0xc0073cea20}, {0x726330, 0xc004dec900}, 0xd, 0x3807)
        /usr/local/go/src/go/types/expr.go:783 +0xa5
go/types.(*Checker).exprInternal(0xc004732000, 0x0, 0xc004ace1c0, {0x725d60, 0xc0073cea50}, {0x0, 0x0})
        /usr/local/go/src/go/types/expr.go:1416 +0x206
go/types.(*Checker).rawExpr(0xc004732000, 0x0, 0xc004ace1c0, {0x725d60?, 0xc0073cea50?}, {0x0?, 0x0?}, 0x0)
        /usr/local/go/src/go/types/expr.go:979 +0x19e
go/types.(*Checker).expr(0xc004732000, 0xc00738fc80?, 0xc004ace1c0, {0x725d60?, 0xc0073cea50?})
        /usr/local/go/src/go/types/expr.go:1513 +0x30
go/types.(*Checker).constDecl(0xc004732000, 0xc00738fd40, {0x0, 0x0}, {0x725d60, 0xc0073cea50}, 0x0)
        /usr/local/go/src/go/types/decl.go:488 +0x328
go/types.(*Checker).objDecl(0xc004732000, {0x729118, 0xc00738fd40}, 0x0)
        /usr/local/go/src/go/types/decl.go:191 +0xa49
go/types.(*Checker).packageObjects(0xc004732000)
        /usr/local/go/src/go/types/resolver.go:693 +0x4dd
go/types.(*Checker).checkFiles(0xc004732000, {0xc0000943b0, 0x1, 0x1})
        /usr/local/go/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
        /usr/local/go/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc0000f41e0, 0xc000a3c7c0)
        /home/todd/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:819 +0x5c5
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /home/todd/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:677 +0x1a9
sync.(*Once).doSlow(0x0?, 0x0?)
        /usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        /usr/local/go/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        /home/todd/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:664 +0x4a
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
        /home/todd/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:671 +0x26
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 518
        /home/todd/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:670 +0x94

Copy link

google-cla bot commented Feb 7, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@stefanb
Copy link

stefanb commented Feb 7, 2024

Maintainers, please also tag a release after merging.

@toddtreece
Copy link
Contributor Author

@zombiezen @vangent it looks like this repo might not be monitored closely at this point. sorry for the ping, but could one of you help with a review on this one?

Copy link
Collaborator

@zombiezen zombiezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zombiezen
Copy link
Collaborator

Looks like you'll need to update the GitHub Actions workflows as well.

@toddtreece
Copy link
Contributor Author

@zombiezen thanks for the review. updated the action in c0cebf2

@zombiezen
Copy link
Collaborator

@vangent, would you mind tagging the release once this goes in? Thanks.

@zombiezen zombiezen merged commit e57deea into google:main Feb 7, 2024
6 checks passed
@akushsky

This comment was marked as resolved.

@Resisty
Copy link

Resisty commented Jul 19, 2024

I'm still getting the following panic with wire 0.6.0 against golang 1.22.5:

120.3 /usr/bin/wire-v0.6.0 gen -tags "oss" ./pkg/server 
458.1 panic: runtime error: invalid memory address or nil pointer dereference [recovered]                        
458.1   panic: runtime error: invalid memory address or nil pointer dereference
458.1 [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x57fb4f]                         
458.1                                                  
458.1 goroutine 267 [running]:                                                                                                          
458.1 go/types.(*Checker).handleBailout(0xc002325800, 0xc003babca8)
458.1   /usr/lib/golang/src/go/types/check.go:367 +0x88                                                                                 
458.1 panic({0x67fd80?, 0x88b400?})                    
458.1   /usr/lib/golang/src/runtime/panic.go:770 +0x132
458.1 go/types.(*StdSizes).Sizeof(0x0, {0x723b78, 0x88f880})
458.1   /usr/lib/golang/src/go/types/sizes.go:228 +0x30f                                                                                
458.1 go/types.(*Config).sizeof(...)                    
458.1   /usr/lib/golang/src/go/types/sizes.go:333
458.1 go/types.representableConst.func1({0x723b78?, 0x88f880?})
458.1   /usr/lib/golang/src/go/types/const.go:76 +0x9e                                                                                  
458.1 go/types.representableConst({0x725598, 0x883dd8}, 0xc002325800, 0x88f880, 0xc003ba9db8)               
458.1   /usr/lib/golang/src/go/types/const.go:106 +0x2c7                                                                                
458.1 go/types.(*Checker).representation(0xc002325800, 0xc00090e600, 0x88f880)                              
458.1   /usr/lib/golang/src/go/types/const.go:256 +0x65
458.1 go/types.(*Checker).representable(0xc002325800, 0xc00090e600, 0x88f880)
458.1   /usr/lib/golang/src/go/types/const.go:239 +0x26
458.1 go/types.(*Checker).shift(0xc002325800, 0xc00090e580, 0xc00090e600, {0x724800, 0xc0038d2210}, 0x14)
458.1   /usr/lib/golang/src/go/types/expr.go:650 +0x1eb                                                                                 
458.1 go/types.(*Checker).binary(0xc002325800, 0xc00090e580, {0x724800, 0xc0038d2210}, {0x724dd0, 0xc00243f000}, {0x724dd0, 0xc00243f020}, 0x14, 0x19fe)
458.1   /usr/lib/golang/src/go/types/expr.go:796 +0x150                                                                                 
458.1 go/types.(*Checker).exprInternal(0xc002325800, 0x0, 0xc00090e580, {0x724800, 0xc0038d2210}, {0x0, 0x0})
458.1   /usr/lib/golang/src/go/types/expr.go:1416 +0x206                                                                                
458.1 go/types.(*Checker).rawExpr(0xc002325800, 0x0, 0xc00090e580, {0x724800?, 0xc0038d2210?}, {0x0?, 0x0?}, 0x0)
458.1   /usr/lib/golang/src/go/types/expr.go:979 +0x19e
458.1 go/types.(*Checker).expr(0xc002325800, 0x0?, 0xc00090e580, {0x724800?, 0xc0038d2210?})
458.1   /usr/lib/golang/src/go/types/expr.go:1513 +0x30
458.1 go/types.(*Checker).binary(0xc002325800, 0xc00090e580, {0x724800, 0xc0038d2240}, {0x724800, 0xc0038d2210}, {0x724dd0, 0xc00243f040}, 0xd, 0x1a02)
458.1   /usr/lib/golang/src/go/types/expr.go:783 +0xa5
458.1 go/types.(*Checker).exprInternal(0xc002325800, 0x0, 0xc00090e580, {0x724800, 0xc0038d2240}, {0x0, 0x0})
458.1   /usr/lib/golang/src/go/types/expr.go:1416 +0x206                                                                                
458.1 go/types.(*Checker).rawExpr(0xc002325800, 0x0, 0xc00090e580, {0x724800?, 0xc0038d2240?}, {0x0?, 0x0?}, 0x0)
458.1   /usr/lib/golang/src/go/types/expr.go:979 +0x19e
458.1 go/types.(*Checker).expr(0xc002325800, 0xc003bd8240?, 0xc00090e580, {0x724800?, 0xc0038d2240?})
458.1   /usr/lib/golang/src/go/types/expr.go:1513 +0x30                                                                                                                                                                                                                         
458.1 go/types.(*Checker).constDecl(0xc002325800, 0xc003bd8300, {0x0, 0x0}, {0x724800, 0xc0038d2240}, 0x0)
458.1   /usr/lib/golang/src/go/types/decl.go:488 +0x2f1                                                                                 
458.1 go/types.(*Checker).objDecl(0xc002325800, {0x727bd8, 0xc003bd8300}, 0x0)      
458.1   /usr/lib/golang/src/go/types/decl.go:191 +0xa49                                                                                 
458.1 go/types.(*Checker).packageObjects(0xc002325800)                                                                                  
458.1   /usr/lib/golang/src/go/types/resolver.go:693 +0x4dd                                                                             
458.1 go/types.(*Checker).checkFiles(0xc002325800, {0xc0000a6180, 0x1, 0x1})
458.1   /usr/lib/golang/src/go/types/check.go:408 +0x1a5
458.1 go/types.(*Checker).Files(...)
458.1   /usr/lib/golang/src/go/types/check.go:372
458.1 golang.org/x/tools/go/packages.(*loader).loadPackage(0xc0000de1e0, 0xc0004a1380)
458.1   /go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:819 +0x5c5
458.1 golang.org/x/tools/go/packages.(*loader).loadRecursive.func1() 
458.1   /go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:677 +0x1a9
458.1 sync.(*Once).doSlow(0x0?, 0x0?)
458.1   /usr/lib/golang/src/sync/once.go:74 +0xc2
458.1 sync.(*Once).Do(...)
458.1   /usr/lib/golang/src/sync/once.go:65
458.1 golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
458.1   /go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:664 +0x4a
458.1 golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
458.1   /go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:671 +0x26
458.1 created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 205
458.1   /go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:670 +0x94
458.1 make: *** [Makefile:80: gen-go] Error 2

@hxiaodon
Copy link

@Resisty , per my understanding, if the wire tool you used is actually 0.6.0, the version of package golang.org/x/tools displayed in your backtrace should be 0.17.0 ,please make a check on this file wire go.mod . The latest wire works well with the go 1.22.5 at my env.

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.

Crashing with Go 1.22
7 participants