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

Fatal error: signal 17 received but handler not on signal stack #52

Open
slytomcat opened this issue Jan 17, 2018 · 3 comments
Open

Fatal error: signal 17 received but handler not on signal stack #52

slytomcat opened this issue Jan 17, 2018 · 3 comments

Comments

@slytomcat
Copy link

slytomcat commented Jan 17, 2018

goqt + go 1.9 + os.exec + fsnotify on Linux 64bit
Call to exec.Command(...).Run() fails on process.wait() with messages:

signal 17 received but handler not on signal stack
fatal error: non-Go code set up signal handler without SA_ONSTACK flag
runtime stack:
runtime.throw(0x5ca8b0, 0x39)
        /home/stc/DEV/GO/usr_local/go/src/runtime/panic.go:605 +0x95
runtime.sigNotOnStack(0x11)
        /home/stc/DEV/GO/usr_local/go/src/runtime/signal_unix.go:540 +0x94
runtime.sigtrampgo(0x11, 0xc4200436f0, 0xc4200435c0)
        /home/stc/DEV/GO/usr_local/go/src/runtime/signal_unix.go:317 +0x367
runtime.sigtramp(0x1, 0x0, 0xc420064000, 0x0, 0x8000, 0x0, 0x0, 0x1000004, 0x212, 0x0, ...)
        /home/stc/DEV/GO/usr_local/go/src/runtime/sys_linux_amd64.s:265 +0x43

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /home/stc/DEV/GO/usr_local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420042fe8 sp=0xc420042fe0 pc=0x4586e1

goroutine 1 [syscall, locked to thread]:
github.com/visualfc/goqt/ui._Cfunc_qtdrv(0xf82ec0, 0x17f500001770, 0xc420016628, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/visualfc/goqt/ui/_obj/_cgo_gotypes.go:180 +0x50
github.com/visualfc/goqt/ui._DirectQtDrv.func1(0xf82ec0, 0x17f500001770, 0xc420016628, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/cdrv.go:137 +0x3bf
github.com/visualfc/goqt/ui._DirectQtDrv(0xf82ec0, 0x17f500001770, 0xc420016628, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/cdrv.go:137 +0xf2
github.com/visualfc/goqt/ui.(*_qt_drv).Drv(0xc420016150, 0x17f500001770, 0xc420016628, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/cdrv.go:280 +0x12d
github.com/visualfc/goqt/ui.(*BaseDrv).Drv(0xc420016150, 0x17f500001770, 0xc420016628, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/cdrv.go:214 +0xfb
github.com/visualfc/goqt/ui.(*QApplication).Exec(0xc420016150, 0xc420046410)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/qt_gui.go:590 +0xd6
github.com/visualfc/goqt/ui.Run.func1(0xc42007a0c0)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/app.go:54 +0x10e
github.com/visualfc/goqt/ui.runInOsMainThread.func1(0xc42007a0c0)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/app.go:28 +0x32
github.com/visualfc/goqt/ui.mainLoop(0x8)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/app.go:18 +0x5c
github.com/visualfc/goqt/ui.Run(0x5cd4a8, 0x53db09)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/app.go:56 +0x7b
main.main()
        /home/stc/DEV/GO/src/github.com/slytomcat/yd-qgo/qgui.go:57 +0x2d

goroutine 5 [chan receive]:
github.com/visualfc/goqt/ui.runInOsMainThread(0xc420046400)
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/app.go:32 +0xbf
created by github.com/visualfc/goqt/ui.Run
        /home/stc/DEV/GO/src/github.com/visualfc/goqt/ui/app.go:45 +0x76

goroutine 6 [syscall]:
syscall.Syscall6(0xe8, 0xa, 0xc4200f3c24, 0x7, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/stc/DEV/GO/usr_local/go/src/syscall/asm_linux_amd64.s:44 +0x5
golang.org/x/sys/unix.EpollWait(0xa, 0xc4200f3c24, 0x7, 0x7, 0xffffffffffffffff, 0xc420001680, 0xc4200ce0c0, 0x0)
        /home/stc/DEV/GO/src/golang.org/x/sys/unix/zsyscall_linux_amd64.go:1529 +0x77
github.com/fsnotify/fsnotify.(*fdPoller).wait(0xc4200146e0, 0x5cd300, 0xc4200146e0, 0x0)
        /home/stc/DEV/GO/src/github.com/fsnotify/fsnotify/inotify_poller.go:86 +0x91
github.com/fsnotify/fsnotify.(*Watcher).readEvents(0xc4200823c0)
        /home/stc/DEV/GO/src/github.com/fsnotify/fsnotify/inotify.go:192 +0x194
created by github.com/fsnotify/fsnotify.NewWatcher
        /home/stc/DEV/GO/src/github.com/fsnotify/fsnotify/inotify.go:59 +0x23a

goroutine 7 [syscall]:
syscall.Syscall6(0xf7, 0x1, 0xa38, 0xc420043ba8, 0x1000004, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/stc/DEV/GO/usr_local/go/src/syscall/asm_linux_amd64.s:44 +0x5
os.(*Process).blockUntilWaitable(0xc420018510, 0xc420018510, 0x0, 0x0)
        /home/stc/DEV/GO/usr_local/go/src/os/wait_waitid.go:31 +0xa5
os.(*Process).wait(0xc420018510, 0xc420060300, 0xc4200cc0d8, 0x48)
        /home/stc/DEV/GO/usr_local/go/src/os/exec_unix.go:22 +0x42
os.(*Process).Wait(0xc420018510, 0x0, 0x0, 0x5cd4e8)
        /home/stc/DEV/GO/usr_local/go/src/os/exec.go:115 +0x2b
os/exec.(*Cmd).Wait(0xc4200cc000, 0x0, 0x0)
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:446 +0x62
os/exec.(*Cmd).Run(0xc4200cc000, 0xc420082410, 0x3)
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:289 +0x5c
os/exec.(*Cmd).Output(0xc4200cc000, 0xb, 0xc420032ea8, 0x3, 0x3, 0xc4200cc000)
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:485 +0x119
github.com/slytomcat/yd-go/ydisk.YDisk.getOutput(0xc4200146a5, 0x15, 0xc420062240, 0xc4200182a0, 0x28, 0xc42007a2a0, 0xc42000c240, 0x1, 0x0, 0x0)
        /home/stc/DEV/GO/src/github.com/slytomcat/yd-go/ydisk/ydisk.go:229 +0xf7
github.com/slytomcat/yd-go/ydisk.(*YDisk).Start(0xc4200602c0)
        /home/stc/DEV/GO/src/github.com/slytomcat/yd-go/ydisk/ydisk.go:249 +0x64
created by main.main.func1
        /home/stc/DEV/GO/src/github.com/slytomcat/yd-qgo/qgui.go:110 +0xfc9

goroutine 8 [runnable]:
os/exec.(*Cmd).Start.func1(0xc4200cc000, 0xc42000c280)
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:380 +0x59
created by os/exec.(*Cmd).Start
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:379 +0x646

goroutine 9 [runnable]:
os/exec.(*Cmd).Start.func1(0xc4200cc000, 0xc42000c2c0)
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:380 +0x59
created by os/exec.(*Cmd).Start
        /home/stc/DEV/GO/usr_local/go/src/os/exec/exec.go:379 +0x646

goroutine 10 [select]:
main.main.func1.7(0xc4200602c0, 0xc4200164b0, 0xc4200164d0, 0xc4200164f0, 0xc420016520, 0xc420016480, 0xc420016560, 0xc42000e048)
        /home/stc/DEV/GO/src/github.com/slytomcat/yd-qgo/qgui.go:177 +0x28e
created by main.main.func1
        /home/stc/DEV/GO/src/github.com/slytomcat/yd-qgo/qgui.go:167 +0xe6e
exit status 2

exec.Command(...).Start() works normally but Run() and Output() that calls to Wait() after Start() fails
Without goqt everything is ok.

Any Idea?

@slytomcat
Copy link
Author

slytomcat commented Jan 18, 2018

Signal 17 - is SIGCHLD in Linux.

waitpid() that is used in golang process.Wait() releases SIGCHLD from child process.

goqt sets (probably) own set of signal handlers. But there is no handler for SIGCHLD in goqt signal handlers (as it said in error message).

And this caused the program failed with unhandled SIGCHLD while SIGCHLD must be ignored in standard situations.

I didn't found yet the way to fix this, but l'll continue th investigation.

@slytomcat
Copy link
Author

Found a workaround but not sure how to fix it in more correct way.

The problem is in the SA_ONSTACK flag. It have to be set on SIGCHLD action for correct handling of SIGCHLD signal in process.Wait().

Workaround:
`
package main

/*
#include <stdio.h>
#include <signal.h>
#include <string.h>

void savesigchld() {
struct sigaction action;
struct sigaction old_action;
sigaction(SIGCHLD, NULL, &action);
action.sa_flags = action.sa_flags | SA_ONSTACK;
sigaction(SIGCHLD, &action, &old_action);
}
*/
import "C"

import (
"github.com/visualfc/goqt/ui"
)
func main() {
ui.Run(func() {
C.savesigchld()
........

`
If I put C.savesigchld() before ui.Run() I got the described problem again.

slytomcat added a commit to slytomcat/yd-qgo that referenced this issue Jan 18, 2018
@slytomcat
Copy link
Author

It seems that it is Qt problem. I found several bug reports related to Qt that Qt redefines the signal handlers (original handler is called by cascade) and loose some action flags during this job.

Probably this issue is not related to goqt directly, but as workaround goqt could update sa_flags after Qt initialization for some commonly used system signals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant