fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.02k stars 1.39k forks source link

close sub window crashed on mac os Ventura (intel chip) #4134

Open chernikite opened 1 year ago

chernikite commented 1 year ago

Checklist

Describe the bug

I open a window from the main window to display the log of the app. When the app starts, I start a thread to simulate writing the log and display the log in the new window. I find that if I write too many logs, when I close the new window At that time, the app will crash. Below is my test code.

the crash log:

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x0]

runtime stack:
runtime.throw({0x1006244ef?, 0xc00322bcb8?})
        /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x700007e4de90 sp=0x700007e4de60 pc=0x100038afd
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:825 +0x3e9 fp=0x700007e4def0 sp=0x700007e4de90 pc=0x10004f1a9
runtime.asmcgocall(0x700007e4df28, 0x100043718)
        /usr/local/go/src/runtime/asm_amd64.s:852 +0x64 fp=0x700007e4def8 sp=0x700007e4def0 pc=0x10006b0e4

goroutine 18 [syscall, locked to thread]:
runtime.cgocall(0x100500ad0, 0xc00322beb0)
        /usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc00322be88 sp=0xc00322be50 pc=0x10000887c
github.com/go-gl/glfw/v3.3/glfw._Cfunc_glfwMakeContextCurrent(0x0)
        _cgo_gotypes.go:1471 +0x45 fp=0xc00322beb0 sp=0xc00322be88 pc=0x1004c2d05
github.com/go-gl/glfw/v3.3/glfw.DetachCurrentContext()
        /Users/xxx/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20221017161538-93cebf72946b/context.go:23 +0x25 fp=0xc00322bed8 sp=0xc00322beb0 pc=0x1004c4d45
fyne.io/fyne/v2/internal/driver/glfw.(*window).DetachCurrentContext(...)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window_desktop.go:639
fyne.io/fyne/v2/internal/driver/glfw.(*window).RunWithContext(0xc00322bf90?, 0xc00379bc80)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:909 +0x55 fp=0xc00322bef8 sp=0xc00322bed8 pc=0x1004dde15
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread.func1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/loop.go:238 +0x13b fp=0xc00322bfe0 sp=0xc00322bef8 pc=0x1004d61db
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00322bfe8 sp=0xc00322bfe0 pc=0x10006b401
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).startDrawThread
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/loop.go:230 +0xea

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x100501ed0, 0xc00006bd60)
        /usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc00006bd38 sp=0xc00006bd00 pc=0x10000887c
github.com/go-gl/glfw/v3.3/glfw._Cfunc_glfwPollEvents()
        _cgo_gotypes.go:1497 +0x45 fp=0xc00006bd60 sp=0xc00006bd38 pc=0x1004c2da5
github.com/go-gl/glfw/v3.3/glfw.PollEvents()
        /Users/xxx/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20221017161538-93cebf72946b/window.go:964 +0x17 fp=0xc00006bd70 sp=0xc00006bd60 pc=0x1004ca697
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).tryPollEvents(0xc00006be80?)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/loop_desktop.go:39 +0x3b fp=0xc00006bd90 sp=0xc00006bd70 pc=0x1004d651b
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).runGL(0xc0003ad3b0)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/loop.go:138 +0x1f9 fp=0xc00006bec0 sp=0xc00006bd90 pc=0x1004d5979
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).Run(0xc0003ad3b0)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/driver.go:169 +0x75 fp=0xc00006bee0 sp=0xc00006bec0 pc=0x1004d3f55
fyne.io/fyne/v2/app.(*fyneApp).Run(0xc000124000?)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/app/app.go:74 +0x37 fp=0xc00006bef8 sp=0xc00006bee0 pc=0x1004e83f7
main.main()
        /Users/xxx/code/gows/fyne-crash/main.go:110 +0x207 fp=0xc00006bf80 sp=0xc00006bef8 pc=0x1004ec3a7
runtime.main()
        /usr/local/go/src/runtime/proc.go:250 +0x207 fp=0xc00006bfe0 sp=0xc00006bf80 pc=0x10003b3a7
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00006bfe8 sp=0xc00006bfe0 pc=0x10006b401

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000058fb0 sp=0xc000058f90 pc=0x10003b7d6
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:387
runtime.forcegchelper()
        /usr/local/go/src/runtime/proc.go:305 +0xb0 fp=0xc000058fe0 sp=0xc000058fb0 pc=0x10003b610
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000058fe8 sp=0xc000058fe0 pc=0x10006b401
created by runtime.init.6
        /usr/local/go/src/runtime/proc.go:293 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000059780 sp=0xc000059760 pc=0x10003b7d6
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
        /usr/local/go/src/runtime/mgcsweep.go:319 +0xde fp=0xc0000597c8 sp=0xc000059780 pc=0x1000282de
runtime.gcenable.func1()
        /usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000597e0 sp=0xc0000597c8 pc=0x10001d706
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000597e8 sp=0xc0000597e0 pc=0x10006b401
created by runtime.gcenable
        /usr/local/go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xd76ede6abc0?, 0xc8878c?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000059f70 sp=0xc000059f50 pc=0x10003b7d6
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x100d09680)
        /usr/local/go/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc000059fa0 sp=0xc000059f70 pc=0x100026173
runtime.bgscavenge(0x0?)
        /usr/local/go/src/runtime/mgcscavenge.go:633 +0x65 fp=0xc000059fc8 sp=0xc000059fa0 pc=0x100026765
runtime.gcenable.func2()
        /usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc000059fe0 sp=0xc000059fc8 pc=0x10001d6a6
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000059fe8 sp=0xc000059fe0 pc=0x10006b401
created by runtime.gcenable
        /usr/local/go/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x1a0?, 0x100d0a060?, 0x60?, 0x78?, 0xc000058770?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000058628 sp=0xc000058608 pc=0x10003b7d6
runtime.runfinq()
        /usr/local/go/src/runtime/mfinal.go:193 +0x107 fp=0xc0000587e0 sp=0xc000058628 pc=0x10001c747
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000587e8 sp=0xc0000587e0 pc=0x10006b401
created by runtime.createfing
        /usr/local/go/src/runtime/mfinal.go:163 +0x45

goroutine 6 [syscall]:
syscall.syscall6(0x0?, 0x0?, 0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/sys_darwin.go:45 +0x99 fp=0xc00005a448 sp=0xc00005a388 pc=0x100067cd9
golang.org/x/sys/unix.kevent(0x0?, 0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /Users/xxx/go/pkg/mod/golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f/unix/zsyscall_darwin_amd64.go:276 +0x52 fp=0xc00005a4b0 sp=0xc00005a448 pc=0x1004e5152
golang.org/x/sys/unix.Kevent(0x0?, {0x0?, 0x0?, 0x0?}, {0xc00005a678?, 0x10000bb65?, 0x0?}, 0x0?)
        /Users/xxx/go/pkg/mod/golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f/unix/syscall_bsd.go:399 +0x3c fp=0xc00005a4f0 sp=0xc00005a4b0 pc=0x1004e507c
github.com/fsnotify/fsnotify.read(0x0?, {0xc00005a678?, 0x0?, 0xa}, 0x0?)
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:525 +0x3f fp=0xc00005a548 sp=0xc00005a4f0 pc=0x1004e7dff
github.com/fsnotify/fsnotify.(*Watcher).readEvents(0xc0000364e0)
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:288 +0xa5 fp=0xc00005a7c8 sp=0xc00005a548 pc=0x1004e6de5
github.com/fsnotify/fsnotify.NewWatcher.func1()
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:63 +0x26 fp=0xc00005a7e0 sp=0xc00005a7c8 pc=0x1004e5c66
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005a7e8 sp=0xc00005a7e0 pc=0x10006b401
created by github.com/fsnotify/fsnotify.NewWatcher
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:63 +0x1c5

goroutine 7 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc00005aeb0 sp=0xc00005ae90 pc=0x10003b7d6
runtime.chanrecv(0xc00008e3c0, 0xc00005afb8, 0x1)
        /usr/local/go/src/runtime/chan.go:583 +0x49d fp=0xc00005af40 sp=0xc00005aeb0 pc=0x10000b61d
runtime.chanrecv2(0x0?, 0x0?)
        /usr/local/go/src/runtime/chan.go:447 +0x18 fp=0xc00005af68 sp=0xc00005af40 pc=0x10000b158
fyne.io/fyne/v2/app.watchFile.func1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/app/settings_desktop.go:43 +0x6c fp=0xc00005afe0 sp=0xc00005af68 pc=0x1004eaa6c
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005afe8 sp=0xc00005afe0 pc=0x10006b401
created by fyne.io/fyne/v2/app.watchFile
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/app/settings_desktop.go:42 +0x111

goroutine 8 [syscall]:
syscall.syscall6(0x0?, 0x0?, 0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/sys_darwin.go:45 +0x99 fp=0xc00005b448 sp=0xc00005b388 pc=0x100067cd9
golang.org/x/sys/unix.kevent(0x0?, 0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /Users/xxx/go/pkg/mod/golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f/unix/zsyscall_darwin_amd64.go:276 +0x52 fp=0xc00005b4b0 sp=0xc00005b448 pc=0x1004e5152
golang.org/x/sys/unix.Kevent(0x0?, {0x0?, 0x0?, 0x0?}, {0xc00005b678?, 0x10000bb65?, 0x0?}, 0x0?)
        /Users/xxx/go/pkg/mod/golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f/unix/syscall_bsd.go:399 +0x3c fp=0xc00005b4f0 sp=0xc00005b4b0 pc=0x1004e507c
github.com/fsnotify/fsnotify.read(0x0?, {0xc00005b678?, 0x0?, 0xa}, 0x0?)
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:525 +0x3f fp=0xc00005b548 sp=0xc00005b4f0 pc=0x1004e7dff
github.com/fsnotify/fsnotify.(*Watcher).readEvents(0xc000036660)
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:288 +0xa5 fp=0xc00005b7c8 sp=0xc00005b548 pc=0x1004e6de5
github.com/fsnotify/fsnotify.NewWatcher.func1()
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:63 +0x26 fp=0xc00005b7e0 sp=0xc00005b7c8 pc=0x1004e5c66
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005b7e8 sp=0xc00005b7e0 pc=0x10006b401
created by github.com/fsnotify/fsnotify.NewWatcher
        /Users/xxx/go/pkg/mod/github.com/fsnotify/fsnotify@v1.5.4/kqueue.go:63 +0x1c5

goroutine 9 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc00005beb0 sp=0xc00005be90 pc=0x10003b7d6
runtime.chanrecv(0xc00008e4e0, 0xc00005bfb8, 0x1)
        /usr/local/go/src/runtime/chan.go:583 +0x49d fp=0xc00005bf40 sp=0xc00005beb0 pc=0x10000b61d
runtime.chanrecv2(0x0?, 0x0?)
        /usr/local/go/src/runtime/chan.go:447 +0x18 fp=0xc00005bf68 sp=0xc00005bf40 pc=0x10000b158
fyne.io/fyne/v2/app.watchFile.func1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/app/settings_desktop.go:43 +0x6c fp=0xc00005bfe0 sp=0xc00005bf68 pc=0x1004eaa6c
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005bfe8 sp=0xc00005bfe0 pc=0x10006b401
created by fyne.io/fyne/v2/app.watchFile
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/app/settings_desktop.go:42 +0x111

goroutine 19 [select]:
runtime.gopark(0xc000066f68?, 0x2?, 0x60?, 0x6f?, 0xc000066f00?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000066d78 sp=0xc000066d58 pc=0x10003b7d6
runtime.selectgo(0xc000066f68, 0xc000066efc, 0x0?, 0x0, 0x0?, 0x1)
        /usr/local/go/src/runtime/select.go:327 +0x7be fp=0xc000066eb8 sp=0xc000066d78 pc=0x10004b35e
fyne.io/fyne/v2/internal/async.(*UnboundedFuncChan).processing(0xc00010e060)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/async/chan_func.go:45 +0xf1 fp=0xc000066fc8 sp=0xc000066eb8 pc=0x1002f9231
fyne.io/fyne/v2/internal/async.NewUnboundedFuncChan.func1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/async/chan_func.go:22 +0x26 fp=0xc000066fe0 sp=0xc000066fc8 pc=0x1002f9106
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000066fe8 sp=0xc000066fe0 pc=0x10006b401
created by fyne.io/fyne/v2/internal/async.NewUnboundedFuncChan
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/async/chan_func.go:22 +0xf8

goroutine 20 [chan receive]:
runtime.gopark(0xc000454048?, 0xc000454040?, 0x60?, 0xfc?, 0xc0004d0000?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000068ee0 sp=0xc000068ec0 pc=0x10003b7d6
runtime.chanrecv(0xc00011c0c0, 0xc000657fb0, 0x1)
        /usr/local/go/src/runtime/chan.go:583 +0x49d fp=0xc000068f70 sp=0xc000068ee0 pc=0x10000b61d
runtime.chanrecv2(0x0?, 0x0?)
        /usr/local/go/src/runtime/chan.go:447 +0x18 fp=0xc000068f98 sp=0xc000068f70 pc=0x10000b158
fyne.io/fyne/v2/internal/driver/common.(*Window).RunEventQueue(0x0?)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/common/window.go:34 +0x4d fp=0xc000068fc8 sp=0xc000068f98 pc=0x1004001ed
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1.1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:946 +0x26 fp=0xc000068fe0 sp=0xc000068fc8 pc=0x1004de3c6
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000068fe8 sp=0xc000068fe0 pc=0x10006b401
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:946 +0x136

goroutine 21 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000055f50 sp=0xc000055f30 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc000055fe0 sp=0xc000055f50 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000055fe8 sp=0xc000055fe0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 34 [GC worker (idle)]:
runtime.gopark(0xd76f3cf03fa?, 0x3?, 0xdd?, 0x8e?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000416750 sp=0xc000416730 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc0004167e0 sp=0xc000416750 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0004167e8 sp=0xc0004167e0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 50 [GC worker (idle)]:
runtime.gopark(0xd76f3d5234e?, 0x3?, 0xf0?, 0x16?, 0xc000114060?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000054f50 sp=0xc000054f30 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc000054fe0 sp=0xc000054f50 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000054fe8 sp=0xc000054fe0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 22 [GC worker (idle)]:
runtime.gopark(0x100d39f80?, 0x1?, 0xa3?, 0xa7?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000056750 sp=0xc000056730 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc0000567e0 sp=0xc000056750 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000567e8 sp=0xc0000567e0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 51 [GC worker (idle)]:
runtime.gopark(0xd76f3ced3d7?, 0x3?, 0x87?, 0xb4?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000412750 sp=0xc000412730 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc0004127e0 sp=0xc000412750 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0004127e8 sp=0xc0004127e0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 23 [GC worker (idle)]:
runtime.gopark(0xd76f3cdf831?, 0x3?, 0xc8?, 0x61?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000056f50 sp=0xc000056f30 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc000056fe0 sp=0xc000056f50 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000056fe8 sp=0xc000056fe0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 52 [GC worker (idle)]:
runtime.gopark(0xd76f3cf0638?, 0x1?, 0x32?, 0x6a?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000412f50 sp=0xc000412f30 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc000412fe0 sp=0xc000412f50 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000412fe8 sp=0xc000412fe0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 24 [GC worker (idle)]:
runtime.gopark(0xd76f3ced474?, 0x3?, 0x26?, 0xed?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000057750 sp=0xc000057730 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc0000577e0 sp=0xc000057750 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000577e8 sp=0xc0000577e0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 53 [GC worker (idle)]:
runtime.gopark(0xd76f3d51201?, 0x3?, 0xec?, 0x5c?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000413750 sp=0xc000413730 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc0004137e0 sp=0xc000413750 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0004137e8 sp=0xc0004137e0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 25 [GC worker (idle)]:
runtime.gopark(0xd76f3d53327?, 0x3?, 0x4b?, 0x71?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000057f50 sp=0xc000057f30 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc000057fe0 sp=0xc000057f50 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000057fe8 sp=0xc000057fe0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 54 [GC worker (idle)]:
runtime.gopark(0xd76f3d51cd3?, 0x1?, 0xbc?, 0x5a?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000413f50 sp=0xc000413f30 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc000413fe0 sp=0xc000413f50 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000413fe8 sp=0xc000413fe0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 26 [GC worker (idle)]:
runtime.gopark(0xd76f3ced5d0?, 0x3?, 0x25?, 0x74?, 0x0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000156750 sp=0xc000156730 pc=0x10003b7d6
runtime.gcBgMarkWorker()
        /usr/local/go/src/runtime/mgc.go:1275 +0xf1 fp=0xc0001567e0 sp=0xc000156750 pc=0x10001f271
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0001567e8 sp=0xc0001567e0 pc=0x10006b401
created by runtime.gcBgMarkStartWorkers
        /usr/local/go/src/runtime/mgc.go:1199 +0x25

goroutine 28 [chan receive]:
runtime.gopark(0xc000418e78?, 0xc000418ed0?, 0xf3?, 0xb2?, 0xc000418ed0?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000418ea0 sp=0xc000418e80 pc=0x10003b7d6
runtime.chanrecv(0xc0004900c0, 0xc000418f88, 0x1)
        /usr/local/go/src/runtime/chan.go:583 +0x49d fp=0xc000418f30 sp=0xc000418ea0 pc=0x10000b61d
runtime.chanrecv2(0xc0004900c0?, 0xc000418f98?)
        /usr/local/go/src/runtime/chan.go:447 +0x18 fp=0xc000418f58 sp=0xc000418f30 pc=0x10000b158
fyne.io/fyne/v2/internal/driver/glfw.catchTerm(0x0?)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/driver.go:188 +0x8f fp=0xc000418fc8 sp=0xc000418f58 pc=0x1004d41af
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).Run.func1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/driver.go:168 +0x26 fp=0xc000418fe0 sp=0xc000418fc8 pc=0x1004d3fc6
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000418fe8 sp=0xc000418fe0 pc=0x10006b401
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).Run
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/driver.go:168 +0x6b

goroutine 35 [select, locked to thread]:
runtime.gopark(0xc000157fa8?, 0x2?, 0x52?, 0xbb?, 0xc000157fa4?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000157e20 sp=0xc000157e00 pc=0x10003b7d6
runtime.selectgo(0xc000157fa8, 0xc000157fa0, 0x0?, 0x0, 0x0?, 0x1)
        /usr/local/go/src/runtime/select.go:327 +0x7be fp=0xc000157f60 sp=0xc000157e20 pc=0x10004b35e
runtime.ensureSigM.func1()
        /usr/local/go/src/runtime/signal_unix.go:1004 +0x187 fp=0xc000157fe0 sp=0xc000157f60 pc=0x1000632a7
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000157fe8 sp=0xc000157fe0 pc=0x10006b401
created by runtime.ensureSigM
        /usr/local/go/src/runtime/signal_unix.go:987 +0xbd

goroutine 55 [syscall]:
runtime.sigNoteSleep(0x0)
        /usr/local/go/src/runtime/os_darwin.go:123 +0x1e fp=0xc0001537a0 sp=0xc000153768 pc=0x100035b9e
os/signal.signal_recv()
        /usr/local/go/src/runtime/sigqueue.go:149 +0x28 fp=0xc0001537c0 sp=0xc0001537a0 pc=0x100067648
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:23 +0x19 fp=0xc0001537e0 sp=0xc0001537c0 pc=0x1004cb6f9
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0001537e8 sp=0xc0001537e0 pc=0x10006b401
created by os/signal.Notify.func1.1
        /usr/local/go/src/os/signal/signal.go:151 +0x2a

goroutine 29 [sleep]:
runtime.gopark(0xd76f926bcec?, 0xc00008c050?, 0x10?, 0x0?, 0xc000466240?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000622f10 sp=0xc000622ef0 pc=0x10003b7d6
time.Sleep(0xf4240)
        /usr/local/go/src/runtime/time.go:195 +0x135 fp=0xc000622f50 sp=0xc000622f10 pc=0x1000681d5
main.logLifecycle.func1.1({0x10070aac8, 0xc00008c730})
        /Users/xxx/code/gows/fyne-crash/main.go:128 +0xcf fp=0xc000622fc0 sp=0xc000622f50 pc=0x1004ec7cf
main.logLifecycle.func1.2()
        /Users/xxx/code/gows/fyne-crash/main.go:131 +0x2e fp=0xc000622fe0 sp=0xc000622fc0 pc=0x1004ec6ce
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000622fe8 sp=0xc000622fe0 pc=0x10006b401
created by main.logLifecycle.func1
        /Users/xxx/code/gows/fyne-crash/main.go:120 +0xab

goroutine 57 [chan receive]:
runtime.gopark(0xc000490720?, 0x0?, 0xb8?, 0x9e?, 0x10000a2e6?)
        /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000419e68 sp=0xc000419e48 pc=0x10003b7d6
runtime.chanrecv(0xc002d838c0, 0x0, 0x1)
        /usr/local/go/src/runtime/chan.go:583 +0x49d fp=0xc000419ef8 sp=0xc000419e68 pc=0x10000b61d
runtime.chanrecv1(0x100cd6a20?, 0xc0003c4900?)
        /usr/local/go/src/runtime/chan.go:442 +0x18 fp=0xc000419f20 sp=0xc000419ef8 pc=0x10000b118
fyne.io/fyne/v2/internal/driver/glfw.runOnDraw(0xc00046c000, 0xc00379bc80)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/loop.go:85 +0x153 fp=0xc000419f98 sp=0xc000419f20 pc=0x1004d53d3
fyne.io/fyne/v2/internal/driver/glfw.(*window).Close(0xc00046c000)
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:211 +0x96 fp=0xc000419fc8 sp=0xc000419f98 pc=0x1004d8bf6
fyne.io/fyne/v2/internal/driver/glfw.(*window).processClosed.func1()
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:277 +0x26 fp=0xc000419fe0 sp=0xc000419fc8 pc=0x1004d9106
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000419fe8 sp=0xc000419fe0 pc=0x10006b401
created by fyne.io/fyne/v2/internal/driver/glfw.(*window).processClosed
        /Users/xxx/go/pkg/mod/fyne.io/fyne/v2@v2.3.5/internal/driver/glfw/window.go:277 +0x6a

Process finished with the exit code 2 

How to reproduce

Run my code below and close the log window when the Scroll bar becomes small, it will crash.

Screenshots

No response

Example code

package main

import (
    "bufio"
    "context"
    "fmt"
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/canvas"
    "fyne.io/fyne/v2/container"
    _ "fyne.io/fyne/v2/driver/desktop"
    "fyne.io/fyne/v2/layout"
    "fyne.io/fyne/v2/theme"
    "fyne.io/fyne/v2/widget"
    "image/color"
    "log"
    "os"
    "time"
)

var i = int64(0)

func ShowLogsWindow(window *fyne.Window) {
    (*window).SetContent(container.NewCenter(widget.NewLabel("LOGS")))
    (*window).Resize(fyne.NewSize(600, 800))
    (*window).SetFixedSize(true)
    logtxt := container.NewVBox()
    logcontainer := container.NewVScroll(logtxt)
    logcontainer.SetMinSize(fyne.NewSize(600, 750))
    vbox := container.NewVBox()
    btnClearLog := &widget.Button{
        Text:       "CLEAR LOG",
        Importance: widget.HighImportance,
        OnTapped: func() {
            logtxt.RemoveAll()
            logtxt.Refresh()
        }}
    boxControl := container.New(layout.NewMaxLayout(), btnClearLog)
    r, w, err := os.Pipe()
    c := new(int64)
    log.SetOutput(w)
    if err != nil {
        fmt.Println("open file log error")
        return
    } else {
        go func() {
            fileScanner := bufio.NewScanner(r)
            fileScanner.Split(bufio.ScanLines)
            for fileScanner.Scan() {
                *c++
                fmt.Println(fileScanner.Text())
                //time.Sleep(time.Second)
                info := canvas.NewText("show logs", &color.RGBA{R: 0, G: 255, B: 0, A: 255})
                info.TextSize = 10
                style := fyne.TextStyle{
                    Bold:      true,
                    Italic:    true,
                    Monospace: true,
                    Symbol:    true,
                    TabWidth:  1,
                }
                info.TextStyle = style
                info.Text = fileScanner.Text()
                info.Refresh()
                logtxt.Add(info)
                logtxt.Refresh()
                if *c%10000 == 0 {
                    //clean log
                    logtxt.RemoveAll()
                }
            }
        }()
    }
    vbox.Add(boxControl)
    vbox.Add(logcontainer)
    (*window).SetContent(vbox)
    (*window).SetOnClosed(func() {
        log.SetOutput(os.Stderr)
        w.Close()
        r.Close()
        //filelog.Close()
        time.Sleep(time.Millisecond * 100)
    })

    (*window).Show()
}

func main() {
    ctx, cancelFunc := context.WithCancel(context.Background())

    log.SetFlags(log.Lmicroseconds)
    //initlogfile()
    a := app.NewWithID("window.crash.demo")
    logLifecycle(a, ctx)
    a.Settings().SetTheme(theme.DarkTheme())
    w := a.NewWindow("crash main window")
    w.Resize(fyne.NewSize(600, 800))
    w.SetFixedSize(true)
    btnstart := widget.NewButton("Start", func() {
        LogsWindow := fyne.CurrentApp().NewWindow("crash window of show logs")
        ShowLogsWindow(&LogsWindow)
    })
    vbox := container.NewCenter(

        btnstart,
    )
    w.SetContent(vbox)
    w.Show()
    a.Run()
    a.Lifecycle().SetOnStopped(func() {
        log.Println("Lifecycle: Stopped")
        cancelFunc()
    })
}
func logLifecycle(a fyne.App, ctx context.Context) {
    a.Lifecycle().SetOnStarted(func() {
        log.Println("Lifecycle: Started")

        go func(ctx context.Context) {
            for {
                select {
                case <-ctx.Done():
                    return
                default:
                    i += 1
                    log.Printf("log.@%d,and i=%d", time.Now().UnixMilli(), i)
                    time.Sleep(time.Millisecond * 1)
                }
            }
        }(ctx)
    })
    a.Lifecycle().SetOnEnteredForeground(func() {
        log.Println("Lifecycle: Entered Foreground")
    })
    a.Lifecycle().SetOnExitedForeground(func() {
        log.Println("Lifecycle: Exited Foreground")
    })
}

Fyne version

v2.3.5

Go compiler version

go 1.20

Operating system and version

macos ventura 13.4

Additional Information

No response

andydotxyz commented 1 year ago

Can you try the develop branch please? There have been a number of fixes to the close handling that are not yet released.

bon-ami commented 11 months ago

fyne 2.4.1. Windows 10 with MinGW.

win1 := myapp.NewWindow(...)
win1.SetContent(...)
win1.SetMaster()
win1.Show()
myapp.Run()
win2 := myapp.NewWindow(...)
win2.SetContent(...)
win2.SetFixedSize(true)
win2.Show()

If I call win2.Close(), it halts. If I manually close the win2 window, open it, close it and open it for the 3rd time, it halts.

andydotxyz commented 11 months ago

You cannot re-show a Closed window, it will be destroyed. If you want to re-use then Hide instead of Close.

If calling Close is indeed crashing that is an issue we should resolve.

bon-ami commented 11 months ago

You cannot re-show a Closed window, it will be destroyed. If you want to re-use then Hide instead of Close.

If calling Close is indeed crashing that is an issue we should resolve.

I did not reuse anything. Sorry I did not make it clear. When I said win2, that code is called as a function, so every time, it is a different instance. Close() in code or manually on a window does not halts it. But several NewWindow(), Show() and Close() in a couple of seconds do. does not occupy my CPU and memory does not increase crazily when it halts.

bon-ami commented 11 months ago

it halts even after I created a third window in a row, without Close() at all.

andydotxyz commented 11 months ago

it halts even after I created a third window in a row, without Close() at all.

This has not been an issue before (fyne_demo can create many windows)... Can you please post a minimal sample that always reproduces this issue?

bon-ami commented 11 months ago

it halts even after I created a third window in a row, without Close() at all.

This has not been an issue before (fyne_demo can create many windows)... Can you please post a minimal sample that always reproduces this issue?

Sadly, I cannot reproduce it with a minimal sample...