You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
searKing
changed the title
runtime: fatal: morestack on g0 and blocking forever when go export functions is called in any signal handlers registered by the non-Go code
runtime: "fatal: morestack on g0" and blocking forever when go export functions is called in any signal handlers registered by the non-Go code
Nov 25, 2019
searKing
added a commit
to searKing/go-issue-call-go-in-c-signal-handler
that referenced
this issue
Nov 25, 2019
I'm sorry, this will never work. A signal handler can only call async-signal-safe functions. Go code will never be async-signal-safe. That would be nearly impossible to implement, and it is not a goal.
I recommend that you open a pipe, read from the pipe on the Go side, and in the signal handler write a byte to the pipe. The write call is async-signal-safe.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The following repository contains an example of the problem:
https://github.com/searKing/go-issue-call-go-in-c-signal-handler
(Note: this code can only be compiled and run on a unix-like system.)
What did you expect to see?
Output:
Got signal: interrupt.
Output:
Got signal: interrupt.
Output:
Got signal: interrupt.
What did you see instead?
Output:
Got signal: interrupt.
Output:
Got none signal in 1s, Time overseed.
Output:
Got none signal in 1s, Time overseed.
if executed in a binary under https://github.com/searKing/go-issue-call-go-in-c-signal-handler/tree/master/cmd,
fatal: morestack on g0
will be printed sometimes.The text was updated successfully, but these errors were encountered: