-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: non-Go code set up signal handler without SA_ONSTACK flag #2134
Comments
This is usually because 2 signal handlers have been installed. Does this help? https://stackoverflow.com/questions/73724723/libfuzzer-go-executable-crashes-with-non-go-code-set-up-signal-handler-without More insight into it happening with libreoffice: https://bugs.documentfoundation.org/show_bug.cgi?id=140189 So sounds like some third party lib is setting up a signal handler that's incompatible with Go's signal handling. |
Thanks, that's interesting! Maybe my program is segfaulting (nil pointer dereference, I'd bet) but something is eating the segfault and not showing the error, so I'm not sure how to debug it. Hmm, so I have one in my program:
But nothing else I import does this, as far as I can tell. Could the third-party lib potentially be something in Wails? (with the (I ran this code for months before using Wails, and never experienced this error. Haven't added other new dependencies since then.) |
I believe multiple signal handlers within Go are just fine. The SA_STACK issue appears to be very specific: it's when a signal handler is created in C without the What does |
I can reproduce it!! Right inside
Obviously, this is a nil pointer dereference. And sure enough, the same So, I think what is happening is my code is panicking (oops) but I can't know where (oops) because of some cgo interaction. Here's the output of
I do actually have go-sqlite as a dependency... I forgot it uses cgo. But that's the only one that does, and I've been using it for months before I used Wails, and haven't encountered this problem before when I had nil pointer dereferences. |
Awesome that you're able to reproduce! What happens if you run it through gdb? Does it give you more clues (better backtrace 🤞 )? |
@leaanthony It just says:
So, it's nice that it reveals the actual source of the signal at this moment! Of course this an induced panic. But if I continue the execution, we still see the problem:
Does that help? |
Thanks for the update. I can reproduce with a bog-standard default template. So firstly, I don't think this is a show-stopper as such because a nil dereference has happened anyway so it's going to go boom. What do you think is the expected behaviour here? It would be good if we can get it to call back to Go's handler. I can only assume there's a standard way of dealing with this scenario and my guess at this point is to include a signal handler in C that overrides the existing one created by the library (I think it's gtk2webkit) with the |
Yeah, exactly, the root cause is in my code, not Wails. The problem is that something about the Wails builds eats the actual error so I can't fix my code 😭 (unless I run without wails, which requires quite a bit of runaround to work with Thanks for looking into it. I'm out of my element here in C libraries. |
I think we can do something here though. If we install a signal handler we may be able to override the existing C signal handler and just propagate that back through to Go. What seems weird to me is that the C signal handler is eating the Go signal. I would have thought that would only have been dealt with by Go |
Makes sense. Yeah, I find it surprising too. |
So I was able to reproduce the original panic in my code while running under
So even with gdb I cannot find the underlying panic and fix it :( |
Oooph that's frustrating. There must be other examples of people using CGO who experience this... |
Not really sure what to look for, but a few things I stumbled upon:
That one comment says:
Is there a similar function for gtk/webkit that Wails calls, do you know? |
Not in Wails, but maybe in gtk/webkit. We can try adding a signal handler like they do in the Magick library and see if that helps. If we set it up in the |
@leaanthony Alright, cool. Thanks. And don't stress on this particular issue; I've spun up my dusty old HTTP server code that I was using before Wails, used it to execute my buggy code path, and found my panic details from a build using Thanks for all you do! |
For anyone having this proble; in the future: check if you have any nil pointer dereference in your code, it might cause this same issue on wails (see: #3965) |
Description
First off, I'm not sure if this is a bug in Wails. It could totally be in my own app! However, I'm not using cgo in my code or my go.mod dependencies (edit: except for sqlite, but that's not new -- and I've never seen this before until using Wails).
This is a similar to #1570, but I'm not using gRPC at all.
My program was running under
wails dev
, and while I wasn't interacting with it, it crashed:Full stack trace is 700 lines. Let me know if you want me to provide it.
When this happened, my program did stop, but the CLI command kept running. I had to send it a signal to stop
wails dev
:To Reproduce
Sadly, I don't know how to reproduce this. It has only happened this one time, and it is not the first time I have run these exact same functions on the exact same inputs. If it happens again I will let you know...UPDATE: Put this right inside
main()
:Expected behaviour
Not crash :)
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
Sorry this isn't the most helpful report. Let me know if you need more info!
The text was updated successfully, but these errors were encountered: