getlantern / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
3.24k stars 446 forks source link

Systray application panics on linux after screen lock #86

Open juja256 opened 5 years ago

juja256 commented 5 years ago

Hello, I have got some issue with my server-like application built with systray package. The application often hangs with SEGFAULT after ubuntu does screen lock. Ubuntu: 18.10 amd64, default Gnome desktop Golang: 1.10

Here is a piece of panic message:

fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0xfe00 pc=0x7eff6c9db254]

runtime stack: runtime.throw(0x99c338, 0x2a) /usr/lib/go-1.10/src/runtime/panic.go:616 +0x81 runtime.sigpanic() /usr/lib/go-1.10/src/runtime/signal_unix.go:372 +0x28e

goroutine 1 [syscall, locked to thread]: runtime.cgocall(0x8746c0, 0xc420069bd0, 0x42b5d8) /usr/lib/go-1.10/src/runtime/cgocall.go:128 +0x64 fp=0xc420069ba0 sp=0xc420069b68 pc=0x41c2d4 github.com/getlantern/systray._Cfunc_nativeLoop(0xc400000000) _cgo_gotypes.go:117 +0x49 fp=0xc420069bd0 sp=0xc420069ba0 pc=0x82b0e9 github.com/getlantern/systray.nativeLoop() /home/grubian/go/src/github.com/getlantern/systray/systray_nonwindows.go:19 +0x22 fp=0xc420069be8 sp=0xc420069bd0 pc=0x82b6a2 github.com/getlantern/systray.Run(0xc4200990e0, 0x9a8db0) /home/grubian/go/src/github.com/getlantern/systray/systray.go:81 +0x77 fp=0xc420069c20 sp=0xc420069be8 pc=0x82a677 main.main.func1(0xc4200f2580)

Maybe I have got some issues with my GTK environment or something else, but if this is a real issue affecting many users it should be fixed.

subsr97 commented 5 years ago

I can't reproduce this issue with the example program on Ubuntu 18.04 amd64 go 1.12.

Can you reproduce this issue with the example program?

hrueschwein commented 2 years ago

Getting this error on Kubuntu 21.04 without screen locking (goos: linux, goarch: amd64) (using Gio for GUI):

Output ``` fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7fdf2046edd4] runtime stack: runtime.throw({0x84be0c?, 0x70?}) /usr/lib/go-1.18/src/runtime/panic.go:992 +0x71 runtime.sigpanic() /usr/lib/go-1.18/src/runtime/signal_unix.go:802 +0x3a9 goroutine 1 [syscall, locked to thread]: runtime.cgocall(0x71e5e0, 0xc0000c9f18) /usr/lib/go-1.18/src/runtime/cgocall.go:157 +0x5c fp=0xc0000c9ef0 sp=0xc0000c9eb8 pc=0x411fbc github.com/getlantern/systray._Cfunc_registerSystray() _cgo_gotypes.go:148 +0x45 fp=0xc0000c9f18 sp=0xc0000c9ef0 pc=0x719bc5 github.com/getlantern/systray.registerSystray(...) /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray_nonwindows.go:14 github.com/getlantern/systray.Register(0x881168?, 0x881160?) /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:106 +0x14b fp=0xc0000c9f40 sp=0xc0000c9f18 pc=0x7193eb github.com/getlantern/systray.Run(0x79a900?, 0xc0000021a0?) /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:77 +0x19 fp=0xc0000c9f60 sp=0xc0000c9f40 pc=0x719219 main.trayRun(...) /home/dikey0ficial/code/lofio/gui/lofio/tray.go:9 main.main() /home/dikey0ficial/code/lofio/gui/lofio/main.go:5 +0x39 fp=0xc0000c9f80 sp=0xc0000c9f60 pc=0x71a479 runtime.main() /usr/lib/go-1.18/src/runtime/proc.go:250 +0x212 fp=0xc0000c9fe0 sp=0xc0000c9f80 pc=0x444bd2 runtime.goexit() /usr/lib/go-1.18/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0000c9fe8 sp=0xc0000c9fe0 pc=0x470761 goroutine 6 [chan receive]: gioui.org/app.(*Window).update(0xc00011e000, 0xff000000ff000001?) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/window.go:177 +0x3f main.(*UI).Run(0xc000110000?, 0xc00011e000) /home/dikey0ficial/code/lofio/gui/lofio/ui.go:48 +0x1f1 main.newWindow() /home/dikey0ficial/code/lofio/gui/lofio/app.go:20 +0xa5 created by main.main /home/dikey0ficial/code/lofio/gui/lofio/main.go:4 +0x25 goroutine 7 [chan receive]: github.com/getlantern/systray.Register.func2() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:93 +0x28 created by github.com/getlantern/systray.Register /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:92 +0xc5 goroutine 18 [select]: gioui.org/app.(*Window).run(0xc00011e000, {0xc000116000?, 0x0?, 0x0?}) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/window.go:911 +0x1d9 created by gioui.org/app.NewWindow /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/window.go:163 +0x496 goroutine 22 [syscall]: gioui.org/internal/egl._Cfunc_eglInitialize(0x7fdee8035eb0, 0xc0004d51f0, 0xc0004d51f4) _cgo_gotypes.go:208 +0x4c gioui.org/internal/egl.eglInitialize.func1(...) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/internal/egl/egl_unix.go:70 gioui.org/internal/egl.eglInitialize(0x71f010?) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/internal/egl/egl_unix.go:70 +0x5d gioui.org/internal/egl.createContext(0x4225e5?) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/internal/egl/egl.go:168 +0x30 gioui.org/internal/egl.NewContext(0x0?) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/internal/egl/egl.go:89 +0x48 gioui.org/app.init.1.func1(0xc0000c0000) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/egl_x11.go:23 +0x29 gioui.org/app.(*x11Window).NewContext(0xc000067990?) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/os_x11.go:135 +0x30 gioui.org/app.(*Window).validateAndProcess(0xc00011e000, {0x8dc968, 0xc0000c0000}, {0x0?, 0x0?}, 0x0?, 0x0?, 0xc00011a180) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/window.go:194 +0x103 gioui.org/app.(*Window).processEvent(0xc00011e000, {0x8dc968, 0xc0000c0000}, {0x8d9680?, 0xc000036480?}) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/window.go:832 +0xc6e gioui.org/app.(*callbacks).Event(0xc00011e4e0, {0x8d9680?, 0xc000036480?}) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/window.go:447 +0x159 gioui.org/app.(*x11Window).loop(0xc0000c0000) /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/os_x11.go:461 +0x35b gioui.org/app.newX11Window.func12() /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/os_x11.go:831 +0x1a5 created by gioui.org/app.newX11Window /home/dikey0ficial/go/pkg/mod/gioui.org@v0.0.0-20220607102828-5cf916c0753c/app/os_x11.go:823 +0x8f5 ```

Sometimes it runs, but crashes are more often

hrueschwein commented 2 years ago

Got new information: i'm getting this only in Xorg, in wayland I haven't it)

hrueschwein commented 2 years ago

Delve says that error is here: https://github.com/getlantern/systray/blob/6065fda28be8c8d91aeb5e20de25e1600b8664a3/systray_linux.c#L147-L148

Delve output (part with systray) ``` > main.trayRun() ./tray.go:9 (hits goroutine(1):1 total:1) (PC: 0x8f78b4) 4: ".../lofio/icon" 5: "github.com/getlantern/systray" 6: ) 7: 8: func trayRun() { => 9: systray.Run(trayOnReady, trayOnExit) 10: } 11: 12: func trayOnReady() { 13: systray.SetIcon(icon.Icon) 14: systray.SetTitle("Lofio") (dlv) s > github.com/getlantern/systray.Run() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:76 (PC: 0x8f6086) 71: } 72: } 73: 74: // Run initializes GUI and starts the event loop, then invokes the onReady 75: // callback. It blocks until systray.Quit() is called. => 76: func Run(onReady func(), onExit func()) { 77: Register(onReady, onExit) 78: nativeLoop() 79: } 80: 81: // Register initializes GUI and registers the callbacks but relies on the (dlv) s > github.com/getlantern/systray.Run() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:77 (PC: 0x8f60a0) 72: } 73: 74: // Run initializes GUI and starts the event loop, then invokes the onReady 75: // callback. It blocks until systray.Quit() is called. 76: func Run(onReady func(), onExit func()) { => 77: Register(onReady, onExit) 78: nativeLoop() 79: } 80: 81: // Register initializes GUI and registers the callbacks but relies on the 82: // caller to run the event loop somewhere else. It's useful if the program (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:86 (PC: 0x8f612a) 81: // Register initializes GUI and registers the callbacks but relies on the 82: // caller to run the event loop somewhere else. It's useful if the program 83: // needs to show other UI elements, for example, webview. 84: // To overcome some OS weirdness, On macOS versions before Catalina, calling 85: // this does exactly the same as Run(). => 86: func Register(onReady func(), onExit func()) { 87: if onReady == nil { 88: systrayReady = func() {} 89: } else { 90: // Run onReady on separate goroutine to avoid blocking event loop 91: readyCh := make(chan interface{}) (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:87 (PC: 0x8f6142) 82: // caller to run the event loop somewhere else. It's useful if the program 83: // needs to show other UI elements, for example, webview. 84: // To overcome some OS weirdness, On macOS versions before Catalina, calling 85: // this does exactly the same as Run(). 86: func Register(onReady func(), onExit func()) { => 87: if onReady == nil { 88: systrayReady = func() {} 89: } else { 90: // Run onReady on separate goroutine to avoid blocking event loop 91: readyCh := make(chan interface{}) 92: go func() { (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:91 (PC: 0x8f614c) 86: func Register(onReady func(), onExit func()) { 87: if onReady == nil { 88: systrayReady = func() {} 89: } else { 90: // Run onReady on separate goroutine to avoid blocking event loop => 91: readyCh := make(chan interface{}) 92: go func() { 93: <-readyCh 94: onReady() 95: }() 96: systrayReady = func() { (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:92 (PC: 0x8f615f) 87: if onReady == nil { 88: systrayReady = func() {} 89: } else { 90: // Run onReady on separate goroutine to avoid blocking event loop 91: readyCh := make(chan interface{}) => 92: go func() { 93: <-readyCh 94: onReady() 95: }() 96: systrayReady = func() { 97: close(readyCh) (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:96 (PC: 0x8f61db) 91: readyCh := make(chan interface{}) 92: go func() { 93: <-readyCh 94: onReady() 95: }() => 96: systrayReady = func() { 97: close(readyCh) 98: } 99: } 100: // unlike onReady, onExit runs in the event loop to make sure it has time to 101: // finish before the process terminates (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:102 (PC: 0x8f627b) 97: close(readyCh) 98: } 99: } 100: // unlike onReady, onExit runs in the event loop to make sure it has time to 101: // finish before the process terminates => 102: if onExit == nil { 103: onExit = func() {} 104: } 105: systrayExit = onExit 106: registerSystray() 107: } (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:105 (PC: 0x8f6295) 100: // unlike onReady, onExit runs in the event loop to make sure it has time to 101: // finish before the process terminates 102: if onExit == nil { 103: onExit = func() {} 104: } => 105: systrayExit = onExit 106: registerSystray() 107: } 108: 109: // Quit the systray 110: func Quit() { (dlv) s > github.com/getlantern/systray.Register() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:106 (PC: 0x8f62c0) 101: // finish before the process terminates 102: if onExit == nil { 103: onExit = func() {} 104: } 105: systrayExit = onExit => 106: registerSystray() 107: } 108: 109: // Quit the systray 110: func Quit() { 111: quitOnce.Do(quit) (dlv) s > github.com/getlantern/systray.registerSystray() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray_nonwindows.go:13 (PC: 0x8f6ea6) 8: 9: import ( 10: "unsafe" 11: ) 12: => 13: func registerSystray() { 14: C.registerSystray() 15: } 16: 17: func nativeLoop() { 18: C.nativeLoop() (dlv) s > github.com/getlantern/systray.registerSystray() /home/dikey0ficial/go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray_nonwindows.go:14 (PC: 0x8f6eb2) 9: import ( 10: "unsafe" 11: ) 12: 13: func registerSystray() { => 14: C.registerSystray() 15: } 16: 17: func nativeLoop() { 18: C.nativeLoop() 19: } (dlv) s > github.com/getlantern/systray._Cfunc_registerSystray() _cgo_gotypes.go:147 (PC: 0x8f6b4f) (dlv) s > github.com/getlantern/systray._Cfunc_registerSystray() _cgo_gotypes.go:148 (PC: 0x8f6b5d) (dlv) s > [runtime-fatal-throw] runtime.throw() /usr/lib/go-1.18/src/runtime/panic.go:982 (hits goroutine(1):1 total:1) (PC: 0x447b20) Warning: debugging optimized function 977: func sync_throw(s string) { 978: throw(s) 979: } 980: 981: //go:nosplit => 982: func throw(s string) { 983: // Everything throw does should be recursively nosplit so it 984: // can be called even when it's unsafe to grow the stack. 985: systemstack(func() { 986: print("fatal error: ", s, "\n") 987: }) (dlv) ```