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

[bug] An error occurs when you run the example code for the master branch on Windows 11 pro #735

Closed
Cardroid opened this issue Nov 28, 2023 · 7 comments · Fixed by #763
Closed
Labels
bug Something isn't working

Comments

@Cardroid
Copy link

Cardroid commented Nov 28, 2023

What happend?

I think it's an error in the mainthread library, is that correct?
How can I fix it?

Exception 0xc0000005 0x0 0xc00017e000 0x7ff7f7659920
PC=0x7ff7f7659920
signal arrived during external code execution

runtime.cgocall(0x7ff7f759a350, 0xc00006fa08)
        C:/Program Files/Go/src/runtime/cgocall.go:157 +0x3e fp=0xc00006f9e0 sp=0xc00006f9a8 pc=0x7ff7f7414e9e
github.com/AllenDang/cimgui-go._Cfunc_ImFontGlyphRangesBuilder_BuildRanges(0xc00008b300, 0x1f196703a80)
        _cgo_gotypes.go:5785 +0x4d fp=0xc00006fa08 sp=0xc00006f9e0 pc=0x7ff7f74d8acd
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges.func1(0x7ff7f74dc786?, 0xc000080000?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/type_accessor.go:98 +0x5d fp=0xc00006fa48 sp=0xc00006fa08 pc=0x7ff7f74e063d
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges({{0x1f196703a80?, 0xc00006fb48?, 0x1f196703ee0?, 0xc00008c378?}}, 0x0?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/type_accessor.go:98 +0x45 fp=0xc00006fa90 sp=0xc00006fa48 pc=0x7ff7f74e0565
github.com/AllenDang/giu.(*FontAtlas).rebuildFontAtlas(0xc0000e2070)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/FontAtlasProsessor.go:268 +0x18b fp=0xc00006fc30 sp=0xc00006fa90 pc=0x7ff7f755840b
github.com/AllenDang/giu.(*MasterWindow).beforeRender(0x0?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:192 +0x55 fp=0xc00006fcb0 sp=0xc00006fc30 pc=0x7ff7f755a835
github.com/AllenDang/giu.(*MasterWindow).beforeRender-fm()
        <autogenerated>:1 +0x25 fp=0xc00006fcc8 sp=0xc00006fcb0 pc=0x7ff7f755c4e5
github.com/AllenDang/cimgui-go.beforeRender()
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/backend.go:36 +0x34 fp=0xc00006fce0 sp=0xc00006fcc8 pc=0x7ff7f74dbb14
_cgoexp_f375fbd198e5_beforeRender(0x0?)
        _cgo_gotypes.go:85384 +0xf fp=0xc00006fcf0 sp=0xc00006fce0 pc=0x7ff7f74e130f
runtime.cgocallbackg1(0x7ff7f74e1300, 0x0?, 0x0)
        C:/Program Files/Go/src/runtime/cgocall.go:329 +0x2c2 fp=0xc00006fdc0 sp=0xc00006fcf0 pc=0x7ff7f7415422
runtime.cgocallbackg(0x7ff7f74527bc?, 0xc000058ea0?, 0x300000002?)
        C:/Program Files/Go/src/runtime/cgocall.go:245 +0x109 fp=0xc00006fe50 sp=0xc00006fdc0 pc=0x7ff7f7415089
runtime.cgocallbackg(0x7ff7f74e1300, 0x230e9ffa6f, 0x0)
        <autogenerated>:1 +0x2e fp=0xc00006fe78 sp=0xc00006fe50 pc=0x7ff7f747ae8e
runtime.cgocallback(0xc00006fed8, 0x7ff7f7414f09, 0x7ff7f759a220)
        C:/Program Files/Go/src/runtime/asm_amd64.s:1035 +0xec fp=0xc00006fea0 sp=0xc00006fe78 pc=0x7ff7f747634c
runtime.systemstack_switch()
        C:/Program Files/Go/src/runtime/asm_amd64.s:474 +0x8 fp=0xc00006feb0 sp=0xc00006fea0 pc=0x7ff7f7474588
runtime.cgocall(0x7ff7f759a220, 0xc00006ff10)
        C:/Program Files/Go/src/runtime/cgocall.go:175 +0xa9 fp=0xc00006fee8 sp=0xc00006feb0 pc=0x7ff7f7414f09
github.com/AllenDang/cimgui-go._Cfunc_igRunLoop(0x1f1966c47e0, 0x7ff7f755ca40, 0x7ff7f755ca80, 0x7ff7f755cac0, 0x7ff7f755cb40)
        _cgo_gotypes.go:29394 +0x4d fp=0xc00006ff10 sp=0xc00006fee8 pc=0x7ff7f74d9f4d
github.com/AllenDang/cimgui-go.(*GLFWBackend).Run.func1(0x1?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/glfw_backend.go:251 +0x9b fp=0xc00006ff70 sp=0xc00006ff10 pc=0x7ff7f74df6fb
github.com/AllenDang/cimgui-go.(*GLFWBackend).Run(0x0?, 0x0?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/glfw_backend.go:251 +0x32 fp=0xc00006ff88 sp=0xc00006ff70 pc=0x7ff7f74df632
main.main.(*MasterWindow).Run.func1()
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:240 +0xcb fp=0xc00006ffb0 sp=0xc00006ff88 pc=0x7ff7f755c9eb
github.com/faiface/mainthread.Run.func1()
        C:/Users/numbe/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:37 +0x23 fp=0xc00006ffe0 sp=0xc00006ffb0 pc=0x7ff7f7557883
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00006ffe8 sp=0xc00006ffe0 pc=0x7ff7f74765c1
created by github.com/faiface/mainthread.Run in goroutine 1
        C:/Users/numbe/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:36 +0xae

goroutine 1 [select, locked to thread]:
runtime.gopark(0xc0000b9ed0?, 0x2?, 0xff?, 0xff?, 0xc0000b9ebc?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc0000b9d68 sp=0xc0000b9d48 pc=0x7ff7f744b14e
runtime.selectgo(0xc0000b9ed0, 0xc0000b9eb8, 0x1f196639378?, 0x0, 0x18?, 0x1)
        C:/Program Files/Go/src/runtime/select.go:327 +0x725 fp=0xc0000b9e88 sp=0xc0000b9d68 pc=0x7ff7f7459c85
github.com/faiface/mainthread.Run(0xc0000080c0)
        C:/Users/numbe/go/pkg/mod/github.com/faiface/[email protected]/mainthread.go:42 +0x10d fp=0xc0000b9f00 sp=0xc0000b9e88 pc=0x7ff7f755782d
github.com/AllenDang/giu.mainthreadCallPlatform(...)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/mainthread_all.go:9
github.com/AllenDang/giu.(*MasterWindow).Run(...)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:232
main.main()
        D:/Lab/Project/go/imgui_test/main.go:15 +0x78 fp=0xc0000b9f40 sp=0xc0000b9f00 pc=0x7ff7f755c8f8
runtime.main()
        C:/Program Files/Go/src/runtime/proc.go:267 +0x2b2 fp=0xc0000b9fe0 sp=0xc0000b9f40 pc=0x7ff7f744ad32
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc0000b9fe8 sp=0xc0000b9fe0 pc=0x7ff7f74765c1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00005bfa8 sp=0xc00005bf88 pc=0x7ff7f744b14e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:404
runtime.forcegchelper()
        C:/Program Files/Go/src/runtime/proc.go:322 +0xb8 fp=0xc00005bfe0 sp=0xc00005bfa8 pc=0x7ff7f744afd8
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00005bfe8 sp=0xc00005bfe0 pc=0x7ff7f74765c1
created by runtime.init.6 in goroutine 1
        C:/Program Files/Go/src/runtime/proc.go:310 +0x1a

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00005df78 sp=0xc00005df58 pc=0x7ff7f744b14e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:404
runtime.bgsweep(0x0?)
        C:/Program Files/Go/src/runtime/mgcsweep.go:280 +0x94 fp=0xc00005dfc8 sp=0xc00005df78 pc=0x7ff7f7434d34
runtime.gcenable.func1()
        C:/Program Files/Go/src/runtime/mgc.go:200 +0x25 fp=0xc00005dfe0 sp=0xc00005dfc8 pc=0x7ff7f742a0c5
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00005dfe8 sp=0xc00005dfe0 pc=0x7ff7f74765c1
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:200 +0x66

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000018070?, 0x7ff7f7a1fd48?, 0x1?, 0x0?, 0xc000058b60?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00006df70 sp=0xc00006df50 pc=0x7ff7f744b14e
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:404
runtime.(*scavengerState).park(0x7ff7f7baf060)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc00006dfa0 sp=0xc00006df70 pc=0x7ff7f7432609
runtime.bgscavenge(0x0?)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc00006dfc8 sp=0xc00006dfa0 pc=0x7ff7f7432b9c
runtime.gcenable.func2()
        C:/Program Files/Go/src/runtime/mgc.go:201 +0x25 fp=0xc00006dfe0 sp=0xc00006dfc8 pc=0x7ff7f742a065
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00006dfe8 sp=0xc00006dfe0 pc=0x7ff7f74765c1
created by runtime.gcenable in goroutine 1
        C:/Program Files/Go/src/runtime/mgc.go:201 +0xa5

goroutine 18 [finalizer wait]:
runtime.gopark(0x7ff7f79c6600?, 0x1f744c001?, 0x0?, 0x0?, 0x7ff7f74534c5?)
        C:/Program Files/Go/src/runtime/proc.go:398 +0xce fp=0xc00005fe28 sp=0xc00005fe08 pc=0x7ff7f744b14e
runtime.runfinq()
        C:/Program Files/Go/src/runtime/mfinal.go:193 +0x107 fp=0xc00005ffe0 sp=0xc00005fe28 pc=0x7ff7f7429187
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc00005ffe8 sp=0xc00005ffe0 pc=0x7ff7f74765c1
created by runtime.createfing in goroutine 1
        C:/Program Files/Go/src/runtime/mfinal.go:163 +0x3d
rax     0x1751
rbx     0x2ea20
rcx     0x1
rdi     0x1f196703a80
rsi     0xc00008b300
rbp     0x1
rsp     0x230e9ff870
r8      0x2021f
r9      0xc0001782bc
r10     0x1ae9
r11     0x1ae8
r12     0x1f196730980
r13     0x2021d
r14     0x1
r15     0x3
rip     0x7ff7f7659920
rflags  0x10216
cs      0x33
fs      0x53
gs      0x2b
exit status 2

this is my go.mod file

module imgui_test

go 1.21.4

require github.com/AllenDang/giu v0.7.1-0.20231114073318-27baeee8d46f

require (
	github.com/AllenDang/cimgui-go v0.0.0-20231009021832-f9856eb4a9a7 // indirect
	github.com/AllenDang/go-findfont v0.0.0-20200702051237-9f180485aeb8 // indirect
	github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3 // indirect
	github.com/mazznoer/csscolorparser v0.1.3 // indirect
	github.com/napsy/go-css v0.0.0-20230611142900-9dd118f3874c // indirect
	github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
	github.com/sahilm/fuzzy v0.1.0 // indirect
	golang.design/x/hotkey v0.4.1 // indirect
	golang.design/x/mainthread v0.3.0 // indirect
	golang.org/x/image v0.14.0 // indirect
	golang.org/x/sys v0.15.0 // indirect
	gopkg.in/eapache/queue.v1 v1.1.0 // indirect
)

Code example

main.go
package main

import (
	"github.com/AllenDang/giu"
)

func loop() {
	giu.SingleWindow().Layout(
		giu.Label("Hello World"),
	)
}

func main() {
	wnd := giu.NewMasterWindow("window title", 600, 400, 0)
	wnd.Run(loop)
}

To Reproduce

  1. Run my demo
  2. will see the crash...

Version

master

OS

windows 11 pro

@Cardroid Cardroid added the bug Something isn't working label Nov 28, 2023
@gucio321
Copy link
Collaborator

Temporarly you can use v0.7.0, I'm working on the fix ;-)

@Cardroid
Copy link
Author

Cardroid commented Nov 29, 2023

Thank you. I'm looking forward to it being fixed. :)

I've tried the https://github.com/ptxmac/cimgui-go/tree/ptx_fixes branch now and here's the result...

2023-11-29.19-30-33.mp4

@gucio321
Copy link
Collaborator

Can I suppose this was fixed? (in #742 )

@Cardroid
Copy link
Author

I'm sorry, but nothing has changed...

I updated the library.

github.com/AllenDang/cimgui-go v0.0.0-20231219093052-24bd5dc22643
github.com/AllenDang/giu v0.7.1-0.20231219095113-bf1aacdc1161

Problem occurs near ImFontGlyphRangesBuilder_BuildRanges.

Exception 0xc0000005 0x0 0xc000324000 0x7ff6f9a8fc20
PC=0x7ff6f9a8fc20
signal arrived during external code execution

runtime.cgocall(0x7ff6f9968ac0, 0xc000243a08)
        C:/Program Files/Go/src/runtime/cgocall.go:157 +0x3e fp=0xc0002439e0 sp=0xc0002439a8 pc=0x7ff6f96a549e
github.com/AllenDang/cimgui-go._Cfunc_ImFontGlyphRangesBuilder_BuildRanges(0xc00002bb20, 0x2025fc88160)
        _cgo_gotypes.go:5809 +0x4d fp=0xc000243a08 sp=0xc0002439e0 pc=0x7ff6f97a160d
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges.func1(0x7ff6f97a6c46?, 0xc000064c00?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/type_accessor.go:98 +0x5d fp=0xc000243a48 sp=0xc000243a08 pc=0x7ff6f97abe7d
github.com/AllenDang/cimgui-go.FontGlyphRangesBuilder.BuildRanges({{0x2025fc88160?, 0xc000243b48?, 0x2025fc8efd0?, 0xc000062440?}}, 0x0?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/type_accessor.go:98 +0x45 fp=0xc000243a90 sp=0xc000243a48 pc=0x7ff6f97abda5
github.com/AllenDang/giu.(*FontAtlas).rebuildFontAtlas(0xc0001589a0)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/FontAtlasProsessor.go:268 +0x18b fp=0xc000243c30 sp=0xc000243a90 pc=0x7ff6f9828dab
github.com/AllenDang/giu.(*MasterWindow).beforeRender(0x0?)
        C:/Users/numbe/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:192 +0x55 fp=0xc000243cb0 sp=0xc000243c30 pc=0x7ff6f982b355
github.com/AllenDang/giu.(*MasterWindow).beforeRender-fm()
        <autogenerated>:1 +0x25 fp=0xc000243cc8 sp=0xc000243cb0 pc=0x7ff6f982fb05
github.com/AllenDang/cimgui-go.beforeRender()
...

@gucio321
Copy link
Collaborator

Ok, I managed to reproduce this on a windows VM - Gonna think about the fix

@gucio321
Copy link
Collaborator

Now this works for cimgui-go. For giu there is a strange sympthom: application starts, runs about... 5 loop iteration and then freezes.
I'll try to find out more.
Could someone confirm my findings ;-)

@gucio321
Copy link
Collaborator

I come with my findings:
The problem is in the mainthread library. I don't know why, but it works with no problems only for linux (maybe because linux is the best os 😄 - but thats my personal opinion only).
For mac we have a special - modified - version of mainthread. It turns out that we need same for windows.
I'll update mianthread to disable it on windows. Also I'm going to openanother issue for that mainthread thing and close this one. - GIU works on windows for me after that fix.
image
lmk if someone still has problems.

gucio321 added a commit to gucio321/giu that referenced this issue Feb 18, 2024
in reference to AllenDang#735 (comment) we have no mainthread
library that works on windows. Due to this fact I think that the best solution is to disable mainthread completely for winows until we find some working solution.

I'll create an issue about this as soon as this change is merged to master
@gucio321 gucio321 linked a pull request Feb 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants