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

[v2] Windows: build with race flag crash with fatal error on windows #1554

Closed
hminbdxxxx opened this issue Jul 13, 2022 · 11 comments
Closed
Labels
awaiting feedback More information is required from the requestor Ready For Testing A fix is available and needs testing
Milestone

Comments

@hminbdxxxx
Copy link

Description

All dependencies are installed. Use wails init -n example and wails build -debug -race, launch the exe and it will show fatal error: checkptr: pointer arithmetic computed bad pointer value.
I tried use wails build -race instead and the exe showed nothing.

To Reproduce

  1. wails init -n example
  2. wails build -debug -race
  3. launch the exe

Expected behaviour

exe and race detactor should work

Screenshots

No response

Attempted Fixes

No response

System Details

Wails CLI v2.0.0-beta.38


Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:             Windows 10 Pro
Version:        2009 (Build: 19044)
ID:             21H2
Go Version:     go1.18
Platform:       windows
Architecture:   amd64

Wails
------
Version:        v2.0.0-beta.38

Dependency      Package Name    Status          Version
----------      ------------    ------          -------
WebView2        N/A             Installed       103.0.1264.49
npm             N/A             Installed       8.3.1
*upx            N/A             Available
*nsis           N/A             Available

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : Available at https://nsis.sourceforge.io/Download

Additional context

full stack trace

PS D:\projects\example> .\build\bin\example.exe
fatal error: checkptr: pointer arithmetic computed bad pointer value

goroutine 1 [running, locked to thread]:
runtime.throw({0x10a3ebe?, 0x8?})
        D:/Go/src/runtime/panic.go:992 +0x76 fp=0xc00007fb00 sp=0xc00007fad0 pc=0x9d8156
runtime.checkptrArithmetic(0xff80000000?, {0x0?, 0x225303028f0?, 0xd0?})
        D:/Go/src/runtime/checkptr.go:52 +0xbb fp=0xc00007fb30 sp=0xc00007fb00 pc=0x9a82bb
github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc/w32.MakeIntResource(...)
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/windows/winc/w32/utils.go:41
github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc.NewIconFromResource(0x9a0000, 0x3)
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/windows/winc/icon.go:32 +0x75 fp=0xc00007fbd0 sp=0xc00007fb30 pc=0xec0ad5
github.com/wailsapp/wails/v2/internal/frontend/desktop/windows.NewWindow({0x0?, 0x0}, 0xc000190000, 0xc000189d40)
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/windows/window.go:74 +0x5d9 fp=0xc00007fd70 sp=0xc00007fbd0 pc=0xeda919
github.com/wailsapp/wails/v2/internal/frontend/desktop/windows.(*Frontend).Run(0xc000180080, {0x121ba58, 0xc000189d10})
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/windows/frontend.go:124 +0x125 fp=0xc00007fe50 sp=0xc00007fd70 pc=0xed1345
github.com/wailsapp/wails/v2/internal/appng.(*App).Run(0xc00004c370)
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/appng/app_production.go:45 +0x6f fp=0xc00007fe90 sp=0xc00007fe50 pc=0xeeb48f
github.com/wailsapp/wails/v2.Run(0xc000190000)
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/wails.go:40 +0x1a6 fp=0xc00007ff00 sp=0xc00007fe90 pc=0xeed966
main.main()
        D:/projects/example/main.go:18 +0x365 fp=0xc00007ff80 sp=0xc00007ff00 pc=0xeedf65
runtime.main()
        D:/Go/src/runtime/proc.go:250 +0x1fe fp=0xc00007ffe0 sp=0xc00007ff80 pc=0x9da81e
runtime.goexit()
        D:/Go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00007ffe8 sp=0xc00007ffe0 pc=0xa070a1

goroutine 6 [syscall]:
os/signal.signal_recv()
        D:/Go/src/runtime/sigqueue.go:151 +0x2f
os/signal.loop()
        D:/Go/src/os/signal/signal_unix.go:23 +0x25
created by os/signal.Notify.func1.1
        D:/Go/src/os/signal/signal.go:151 +0x51

goroutine 7 [chan receive]:
github.com/wailsapp/wails/v2/internal/signal.Start.func1()
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/signal/signal.go:31 +0x3f
created by github.com/wailsapp/wails/v2/internal/signal.Start
        C:/Users/ThinkPad/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/signal/signal.go:29 +0xb7
@stffabi
Copy link
Collaborator

stffabi commented Jul 13, 2022

Thanks for reporting this issue and using Wails.

The race detector flag also executes some unsafe pointer arithmetic checks, and has found a violation here. This needs to be fixed in the native library used in Wails.

For the time being you could simply disable the race detector until we have fix for that and you should be able to run your application.

Also sounds like we have never run an app with active race detector on Windows. So there might be other cases as well, which needs some fixes.

@hminbdxxxx
Copy link
Author

hminbdxxxx commented Jul 13, 2022

I tried the Minimal Demo in https://github.com/tadvi/winc with go run -race main.go, got same error.
Maybe helpful for fixing this

fatal error: checkptr: pointer arithmetic computed bad pointer value

goroutine 1 [running, locked to thread]:
runtime.throw({0x832505?, 0x8?})
        D:/Go/src/runtime/panic.go:992 +0x76 fp=0xc00014ddc0 sp=0xc00014dd90 pc=0x760d36
runtime.checkptrArithmetic(0xffffffff80000000?, {0x0?, 0x0?, 0x6f0000?})
        D:/Go/src/runtime/checkptr.go:52 +0xbb fp=0xc00014ddf0 sp=0xc00014ddc0 pc=0x73319b
github.com/tadvi/winc/w32.MakeIntResource(...)
        C:/Users/ThinkPad/go/pkg/mod/github.com/tadvi/[email protected]/w32/utils.go:41
github.com/tadvi/winc.NewIconFromResource(0x6f0000, 0x3)
        C:/Users/ThinkPad/go/pkg/mod/github.com/tadvi/[email protected]/icon.go:32 +0x75 fp=0xc00014de90 sp=0xc00014ddf0 pc=0x7fb755
github.com/tadvi/winc.NewForm({0x0?, 0x0})
        C:/Users/ThinkPad/go/pkg/mod/github.com/tadvi/[email protected]/form.go:72 +0x130 fp=0xc00014df08 sp=0xc00014de90 pc=0x7fa7b0
main.main()
        D:/projects/example/winc/main.go:8 +0x2e fp=0xc00014df80 sp=0xc00014df08 pc=0x801c2e
runtime.main()
        D:/Go/src/runtime/proc.go:250 +0x1fe fp=0xc00014dfe0 sp=0xc00014df80 pc=0x76333e
runtime.goexit()
        D:/Go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00014dfe8 sp=0xc00014dfe0 pc=0x78b581
exit status 2

@leaanthony leaanthony added awaiting feedback More information is required from the requestor Ready For Testing A fix is available and needs testing labels Jul 13, 2022
@leaanthony
Copy link
Member

Hi @hminbdxxxx - there's a fix in the linked PR. Please let us know how you get on 👍

@leaanthony leaanthony added this to the v2.0.0 milestone Jul 13, 2022
@hminbdxxxx
Copy link
Author

Hi @leaanthony
I tested go build -race with linked PR branch and there are no fatal errors anymore, but the window icon doesn't seem to work, I found that v2/internal/frontend/desktop/windows/winc/icon.go calls func MakeIntResource, maybe it's broken?
1

this is built with v2.0.0-beta.38
2

@leaanthony
Copy link
Member

Wow, great spotting! Perhaps it needs to be a reference to itself rather than a copy. You could try just a return &id instead?

@stffabi
Copy link
Collaborator

stffabi commented Jul 17, 2022

@hminbdxxxx we have updated the PR with another approach to fix this. Would it be possible for you to give it another try?

@leaanthony
Copy link
Member

I believe this is working, however we aren't out of the woods yet as the recent screen dimensions PR seems to now be exhibiting the same behaviour, specifically:

	screenContainer := (*ScreenContainer)(unsafe.Pointer(dwData))

I'll see if I can update this.

@stffabi
Copy link
Collaborator

stffabi commented Jul 17, 2022

Oh that's interesting, I would have expected this to work because it maps to a valid memory location retrieved by

succeeded := w32.EnumDisplayMonitors(dc, nil, syscall.NewCallback(EnumProc), uintptr(unsafe.Pointer(&monitorContainer)))

@leaanthony
Copy link
Member

I can confirm that not calling ScreenGetAll does indicate that this PR works just fine for the problem intended. Now the question is whether to fix ScreenGetAll in this PR or not :-)

@leaanthony
Copy link
Member

Pushed a fix. I think this is good to go

@hminbdxxxx
Copy link
Author

It works fine now, thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback More information is required from the requestor Ready For Testing A fix is available and needs testing
Projects
None yet
Development

No branches or pull requests

3 participants