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

panic when building with go 1.22 and wails 2.7.1 on Windows #3242

Closed
acastruc opened this issue Feb 7, 2024 · 13 comments · Fixed by #3244
Closed

panic when building with go 1.22 and wails 2.7.1 on Windows #3242

acastruc opened this issue Feb 7, 2024 · 13 comments · Fixed by #3244
Labels
Bug Something isn't working External Issue Not a Wails issue but something wrong with an external dependency Not a Wails Issue

Comments

@acastruc
Copy link

acastruc commented Feb 7, 2024

Description

On a fresh Windows VM, I installed Go 1.22 , then attempted to build a project that used wails v2.7.1. I ran wails build [-clean] and got a panic message.

> wails build
Wails CLI v2.7.1
# Build Options

Platform(s)        | windows/amd64
Compiler           | C:\Program Files\Go\bin\go.exe
Skip Bindings      | false
Build Mode         | production
Devtools           | false
Frontend Directory | C:\Users\me\app\frontend
Obfuscated         | false
Skip Frontend      | false
Compress           | false
Package            | true
Clean Bin Dir      | false
LDFlags            |
Tags               | []
Race Detector      | false

# Building target: windows/amd64

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1259f9e]

goroutine 15 [running]:
go/types.(*Checker).handleBailout(0xc0000dbc00, 0xc00045bbd0)
        C:/Program Files/Go/src/go/types/check.go:367 +0x88
panic({0x1b259c0?, 0x2869b70?})
        C:/Program Files/Go/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0x1fb8db8, 0x28772e0})
        C:/Program Files/Go/src/go/types/sizes.go:228 +0x31e
go/types.(*Config).sizeof(...)
        C:/Program Files/Go/src/go/types/sizes.go:333
go/types.representableConst.func1({0x1fb8db8?, 0x28772e0?})
        C:/Program Files/Go/src/go/types/const.go:76 +0x9e
go/types.representableConst({0x1fbbfa0, 0x262a9e8}, 0xc0000dbc00, 0x28772e0, 0xc0004595d0)
        C:/Program Files/Go/src/go/types/const.go:92 +0x192
go/types.(*Checker).representation(0xc0000dbc00, 0xc000463280, 0x28772e0)
        C:/Program Files/Go/src/go/types/const.go:256 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc0000dbc00, 0xc000463280, {0x1fb8db8, 0x28772e0})
        C:/Program Files/Go/src/go/types/expr.go:375 +0x30d
go/types.(*Checker).assignment(0xc0000dbc00, 0xc000463280, {0x1fb8db8, 0x28772e0}, {0xc000332bd0, 0x14})
        C:/Program Files/Go/src/go/types/assignments.go:52 +0x2e5
go/types.(*Checker).arguments(0xc0000dbc00, 0xc001367b00, 0xc000463240, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0xc001175920, ...}, ...)
        C:/Program Files/Go/src/go/types/call.go:654 +0x13dc
go/types.(*Checker).callExpr(0xc0000dbc00, 0xc000463200, 0xc001367b00)
        C:/Program Files/Go/src/go/types/call.go:304 +0x6e9
go/types.(*Checker).exprInternal(0xc0000dbc00, 0x0, 0xc000463200, {0x1fbadd0, 0xc001367b00}, {0x0, 0x0})
        C:/Program Files/Go/src/go/types/expr.go:1374 +0xf8
go/types.(*Checker).rawExpr(0xc0000dbc00, 0x0, 0xc000463200, {0x1fbadd0?, 0xc001367b00?}, {0x0?, 0x0?}, 0x0)
        C:/Program Files/Go/src/go/types/expr.go:979 +0x19e
go/types.(*Checker).stmt(0xc0000dbc00, 0x0, {0x1fba980, 0xc00132f0b0})
        C:/Program Files/Go/src/go/types/stmt.go:394 +0x12d
go/types.(*Checker).stmtList(0xc0000dbc00, 0x0, {0xc0003ef300?, 0x0?, 0x2e?})
        C:/Program Files/Go/src/go/types/stmt.go:121 +0x85
go/types.(*Checker).funcBody(0xc0000dbc00, 0x1fb8e08?, {0xc000236d10?, 0xc00017cc40?}, 0xc00042b7c0, 0xc000e89aa0, {0x0?, 0x0?})
        C:/Program Files/Go/src/go/types/stmt.go:41 +0x331
go/types.(*Checker).funcDecl.func1()
        C:/Program Files/Go/src/go/types/decl.go:852 +0x3a
go/types.(*Checker).processDelayed(0xc0000dbc00, 0x0)
        C:/Program Files/Go/src/go/types/check.go:467 +0x162
go/types.(*Checker).checkFiles(0xc0000dbc00, {0xc0002f33e0, 0x4, 0x4})
        C:/Program Files/Go/src/go/types/check.go:411 +0x1cc
go/types.(*Checker).Files(...)
        C:/Program Files/Go/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc00014c380, 0xc0004164b0)
        C:/Users/me/go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:1052 +0xa72
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        C:/Users/me/go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:851 +0x1a9
sync.(*Once).doSlow(0xc00055df98?, 0x0?)
        C:/Program Files/Go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        C:/Program Files/Go/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x1?, 0xc00055dfd0?)
        C:/Users/me/go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:839 +0x4a
golang.org/x/tools/go/packages.(*loader).refine.func2(0x0?)
        C:/Users/me/go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:774 +0x26
created by golang.org/x/tools/go/packages.(*loader).refine in goroutine 1
        C:/Users/me/go/pkg/mod/golang.org/x/tools@v0.6.0/go/packages/packages.go:773 +0xccf

To Reproduce

  1. Install Go 1.22 https://tip.golang.org/doc/go1.22
  2. Install wails v2.7.1 and all necessary dependencies
  3. I used an existing wails project (cannot share source) I am working on but I bet it would work on a new vanilla project from template
  4. Run wails build [-clean] from project root.
    result: panic
    I then installed go 1.21.x, problem still occurred. I verified go version with go version
    I searched my HD and only found the 1 go binary (1.21)
    I found it curious that wails doctor still indicated it was Go 1.22.
    As a last resort I had to delete wails and reinstall before it worked again.

Expected behaviour

The wails build command should generate a binary as normal with go1.22. No panic.

Screenshots

image

Attempted Fixes

I installed go 1.21, ran build command again. Panic still occurred.
Verified go version with go version -> 1.21
I ran wails doctor and it indicated go 1.22 ? This puzzled me.
Had to reinstall wails before build worked.

System Details

wails doctor


          Wails Doctor          
                                


# Wails
Version | v2.7.1

# System
┌───────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Windows 10 Enterprise                                                  |
| Version      | 2009 (Build: 22000)                                                    |
| ID           | 21H2                                                                   |
| Go Version   | go1.22.0                                                               |
| Platform     | windows                                                                |
| Architecture | amd64                                                                  |
| CPU          | Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz                          |
| GPU 1        | Microsoft Hyper-V Video (Microsoft) - Driver: 10.0.22000.1             |
| GPU 2        | Microsoft Remote Display Adapter (Microsoft) - Driver: 10.0.22000.2600 |
| Memory       | 4GB                                                                    |
└───────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version       |
| WebView2   | N/A          | Installed | 121.0.2277.98 |
| Nodejs     | N/A          | Installed | 20.11.0       |
| npm        | N/A          | Installed | 10.2.4        |
| *upx       | N/A          | Available |               |
| *nsis      | N/A          | Available |               |
└─────────────── * - Optional Dependency ───────────────┘

# Diagnosis
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Additional context

No response

@acastruc acastruc added the Bug Something isn't working label Feb 7, 2024
@acastruc acastruc changed the title panic when building with go 1.22 and wails 2.7.1 panic when building with go 1.22 and wails 2.7.1 on Windows Feb 7, 2024
@leaanthony
Copy link
Member

leaanthony commented Feb 7, 2024

It could be a mismatch between a 1.21 built CLI and a 1.22 built project. I'm not sure how... perhaps an issue with the Go module cache? Could you please try 1.22 again but make sure you clean out the Go caches:

  • go clean -cache
  • go clean -modcache
  • Install Wails CLI using Go 1.22
  • Generate project
  • wails build

@acastruc
Copy link
Author

acastruc commented Feb 7, 2024

I could but as I mentioned it was a fresh VM with fresh Go install and fresh wails install.

@leaanthony
Copy link
Member

I just reproduced it. Absolutely looks like an issue with Go itself. I'll try open an issue on the Go repo today

@leaanthony leaanthony added Not a Wails Issue External Issue Not a Wails issue but something wrong with an external dependency labels Feb 7, 2024
@acastruc
Copy link
Author

acastruc commented Feb 7, 2024

Ohh (waves hand), I'm no hero...

@acastruc
Copy link
Author

acastruc commented Feb 7, 2024

Been tinkering switching between go versions

so "go install wails" with 1.21 creates a good wails CLI (build works)
"go install wails" with 1.22 creates bad wails CLI (panic)

just fyi, not sure if this informs anything you didnt already know.

@leaanthony
Copy link
Member

Do you use Goland or VSC? Perhaps if we create a new project using the -ide flag and load it in the IDE, we could run it in debug mode and hopefully get some context about which Go command is causing this.

@acastruc
Copy link
Author

acastruc commented Feb 8, 2024

@leaanthony both. We have multiple devs on our team, some use Goland on win, some VSCode.

@stffabi
Copy link
Collaborator

stffabi commented Feb 8, 2024

I was also able to reproduce it on macOS. Building wails cli with go1.22.0. It also happens with wails dev just after executing go mod tidy. Manually building the wails app directly with go works also.

The culprit seems to be golang.org/x/tools, after updating it to at least v0.13.0 the wails cli started to be working again, if the cli was built with go1.22.

It seems like the issue has already been reported at the go repo golang/go#64812

@stffabi
Copy link
Collaborator

stffabi commented Feb 8, 2024

PR to bump x/tools is up #3244

@stffabi
Copy link
Collaborator

stffabi commented Feb 8, 2024

@acastruc would it be possible for you to give the PR #3244 a try?

@acastruc
Copy link
Author

acastruc commented Feb 8, 2024

@acastruc would it be possible for you to give the PR #3244 a try?

standby

@acastruc
Copy link
Author

acastruc commented Feb 8, 2024

@stffabi fix verified, thanks

@leaanthony
Copy link
Member

Released as part of v2.8 👍

@coderabbitai coderabbitai bot mentioned this issue Mar 1, 2024
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working External Issue Not a Wails issue but something wrong with an external dependency Not a Wails Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants