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

Crashing with Go 1.22 #400

Closed
Tracked by #157782
stefanb opened this issue Jan 30, 2024 · 3 comments · Fixed by #401
Closed
Tracked by #157782

Crashing with Go 1.22 #400

stefanb opened this issue Jan 30, 2024 · 3 comments · Fixed by #401

Comments

@stefanb
Copy link

stefanb commented Jan 30, 2024

Describe the bug

Does not work with Go 1.22 (both rc1 and rc2, final is scheduled to be released this February 2024).

Found the problem when trying to run wire in Grafana (see grafana/grafana#80514) but the problem is also reproducable in the Go tests in this rpository.

To Reproduce

  1. Install Go 1.22 rc1 or rc2 (eg using the usual go install golang.org/dl/go1.22rc2@latest && go1.22rc2 download or from https://go.dev/dl/)
  2. checkout this repository
  3. run tests go1.22rc2 test ./...
  4. See error:
wire|main ⇒  go1.22rc2 test ./...                    
?       github.com/google/wire  [no test files]
?       github.com/google/wire/cmd/wire [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=0x1042528a0]

goroutine 242 [running]:
go/types.(*Checker).handleBailout(0x140005d2600, 0x1400051fc38)
        /Users/xxx/sdk/go1.22rc2/src/go/types/check.go:367 +0x9c
panic({0x10438f260?, 0x10456c4d0?})
        /Users/xxx/sdk/go1.22rc2/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x1043dae70, 0x104571080})
        /Users/xxx/sdk/go1.22rc2/src/go/types/sizes.go:228 +0x320
go/types.(*Config).sizeof(...)
        /Users/xxx/sdk/go1.22rc2/src/go/types/sizes.go:333
go/types.representableConst.func1({0x1043dae70?, 0x104571080?})
        /Users/xxx/sdk/go1.22rc2/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x1043dcfb8, 0x104563be0}, 0x140005d2600, 0x104571080, 0x1400051f388)
        /Users/xxx/sdk/go1.22rc2/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x140005d2600, 0x1400088c8c0, 0x104571080)
        /Users/xxx/sdk/go1.22rc2/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x140005d2600, 0x1400088c8c0, {0x1043dae98, 0x14000684150})
        /Users/xxx/sdk/go1.22rc2/src/go/types/expr.go:375 +0x340
go/types.(*Checker).assignment(0x140005d2600, 0x1400088c8c0, {0x1043dae98, 0x14000684150}, {0x1042f1589, 0x14})
        /Users/xxx/sdk/go1.22rc2/src/go/types/assignments.go:52 +0x23c
go/types.(*Checker).initConst(0x140005d2600, 0x140003a6e40, 0x1400088c8c0)
        /Users/xxx/sdk/go1.22rc2/src/go/types/assignments.go:126 +0x304
go/types.(*Checker).constDecl(0x140005d2600, 0x140003a6e40, {0x1043dbe50, 0x140003bac40}, {0x1043dbe50, 0x140003bac60}, 0x0)
        /Users/xxx/sdk/go1.22rc2/src/go/types/decl.go:490 +0x298
go/types.(*Checker).objDecl(0x140005d2600, {0x1043df6f8, 0x140003a6e40}, 0x0)
        /Users/xxx/sdk/go1.22rc2/src/go/types/decl.go:191 +0x84c
go/types.(*Checker).packageObjects(0x140005d2600)
        /Users/xxx/sdk/go1.22rc2/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x140005d2600, {0x140000a0108, 0x3, 0x3})
        /Users/xxx/sdk/go1.22rc2/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/xxx/sdk/go1.22rc2/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0x14000330000, 0x140004c2960)
        /Users/xxx/go/pkg/mod/golang.org/x/tools@v0.1.0/go/packages/packages.go:955 +0x5e8
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /Users/xxx/go/pkg/mod/golang.org/x/tools@v0.1.0/go/packages/packages.go:793 +0x178
sync.(*Once).doSlow(0x0?, 0x0?)
        /Users/xxx/sdk/go1.22rc2/src/sync/once.go:74 +0x100
sync.(*Once).Do(...)
        /Users/xxx/sdk/go1.22rc2/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x1?)
        /Users/xxx/go/pkg/mod/golang.org/x/tools@v0.1.0/go/packages/packages.go:781 +0x50
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
        /Users/xxx/go/pkg/mod/golang.org/x/tools@v0.1.0/go/packages/packages.go:788 +0x30
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 225
        /Users/xxx/go/pkg/mod/golang.org/x/tools@v0.1.0/go/packages/packages.go:787 +0x84
FAIL    github.com/google/wire/internal/wire    0.552s
FAIL

Expected behavior

Expected the tests to pass (or to fail the same way as with Go 1.21)

Version

Tests ran on current HEAD on main branch: 0675cdc

grafana/grafana#80514 uses latest release 0.5.0

Additional context

Noticed problems when testing

Raised the issue in Grafana:

@stefanb stefanb changed the title Tests failing with Go 1.22 Not working with Go 1.22 Jan 30, 2024
@stefanb stefanb changed the title Not working with Go 1.22 Crashing with Go 1.22 Jan 31, 2024
@Chris-Sheridan
Copy link

I have the same issue. Has anyone looked at it yet?

@stefanb
Copy link
Author

stefanb commented Feb 7, 2024

@Chris-Sheridan the proposed fix is in #401

@koddr
Copy link

koddr commented Feb 7, 2024

Yep, the same issue here.

After upgrade to the release Go version 1.22.0:

$ go run github.com/google/wire/cmd/wire@latest ./...

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=0x102eaa670]

goroutine 92 [running]:
go/types.(*Checker).handleBailout(0x140007a6000, 0x1400089dc78)
        /Users/user/sdk/go1.22.0/src/go/types/check.go:367 +0x9c
panic({0x102ff98c0?, 0x103196580?})
        /Users/user/sdk/go1.22.0/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x103038e18, 0x10319a880})
        /Users/user/sdk/go1.22.0/src/go/types/sizes.go:228 +0x320
go/types.(*Config).sizeof(...)
        /Users/user/sdk/go1.22.0/src/go/types/sizes.go:333
go/types.representableConst.func1({0x103038e18?, 0x10319a880?})
        /Users/user/sdk/go1.22.0/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x10303a808, 0x10318ef40}, 0x140007a6000, 0x10319a880, 0x1400089c078)
        /Users/user/sdk/go1.22.0/src/go/types/const.go:92 +0x138
go/types.(*Checker).representation(0x140007a6000, 0x14000890bc0, 0x10319a880)
        /Users/user/sdk/go1.22.0/src/go/types/const.go:256 +0x68
go/types.(*Checker).implicitTypeAndValue(0x140007a6000, 0x14000890bc0, {0x103038e18, 0x10319a880})
        /Users/user/sdk/go1.22.0/src/go/types/expr.go:375 +0x340
go/types.(*Checker).convertUntyped(0x140007a6000, 0x14000890bc0, {0x103038e18, 0x10319a880})
        /Users/user/sdk/go1.22.0/src/go/types/const.go:289 +0x30
go/types.(*Checker).matchTypes(0x140007a6000, 0x14000890b80, 0x14000890bc0)
        /Users/user/sdk/go1.22.0/src/go/types/expr.go:926 +0x7c
go/types.(*Checker).binary(0x140007a6000, 0x14000890b80, {0x103039aa0, 0x14000511680}, {0x103039b30, 0x1400050ace0}, {0x10303a070, 0x1400050ad00}, 0x28, 0x133)
        /Users/user/sdk/go1.22.0/src/go/types/expr.go:800 +0x114
go/types.(*Checker).exprInternal(0x140007a6000, 0x0, 0x14000890b80, {0x103039aa0, 0x14000511680}, {0x0, 0x0})
        /Users/user/sdk/go1.22.0/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x140007a6000, 0x0, 0x14000890b80, {0x103039aa0?, 0x14000511680?}, {0x0?, 0x0?}, 0x0)
        /Users/user/sdk/go1.22.0/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x140007a6000, 0x1030391b0?, 0x14000890b80, {0x103039aa0?, 0x14000511680?})
        /Users/user/sdk/go1.22.0/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).stmt(0x140007a6000, 0x0, {0x103039e90, 0x140004c7940})
        /Users/user/sdk/go1.22.0/src/go/types/stmt.go:570 +0xdb0
go/types.(*Checker).stmtList(0x140007a6000, 0x0, {0x1400050ae60?, 0x0?, 0x0?})
        /Users/user/sdk/go1.22.0/src/go/types/stmt.go:121 +0x88
go/types.(*Checker).funcBody(0x140007a6000, 0x103038e18?, {0x140004eb790?, 0x10319aa60?}, 0x140008908c0, 0x14000511710, {0x0?, 0x0?})
        /Users/user/sdk/go1.22.0/src/go/types/stmt.go:41 +0x21c
go/types.(*Checker).funcDecl.func1()
        /Users/user/sdk/go1.22.0/src/go/types/decl.go:852 +0x44
go/types.(*Checker).processDelayed(0x140007a6000, 0x0)
        /Users/user/sdk/go1.22.0/src/go/types/check.go:467 +0x12c
go/types.(*Checker).checkFiles(0x140007a6000, {0x140000580b8, 0x1, 0x1})
        /Users/user/sdk/go1.22.0/src/go/types/check.go:411 +0x188
go/types.(*Checker).Files(...)
        /Users/user/sdk/go1.22.0/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0x140001501e0, 0x1400049dd40)
        /Users/user/go/pkg/mod/golang.org/x/tools@v0.0.0-20190422233926-fe54fb35175b/go/packages/packages.go:819 +0x4f4
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /Users/user/go/pkg/mod/golang.org/x/tools@v0.0.0-20190422233926-fe54fb35175b/go/packages/packages.go:677 +0x178
sync.(*Once).doSlow(0x0?, 0x0?)
        /Users/user/sdk/go1.22.0/src/sync/once.go:74 +0x100
sync.(*Once).Do(...)
        /Users/user/sdk/go1.22.0/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        /Users/user/go/pkg/mod/golang.org/x/tools@v0.0.0-20190422233926-fe54fb35175b/go/packages/packages.go:664 +0x50
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
        /Users/user/go/pkg/mod/golang.org/x/tools@v0.0.0-20190422233926-fe54fb35175b/go/packages/packages.go:671 +0x30
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1 in goroutine 65
        /Users/user/go/pkg/mod/golang.org/x/tools@v0.0.0-20190422233926-fe54fb35175b/go/packages/packages.go:670 +0x84
exit status 2

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 a pull request may close this issue.

3 participants