-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
main: properly handle SIGINT #75999
main: properly handle SIGINT #75999
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Could close the 10 years old #8417 too ? |
Does this fix the root cause of the heap overflow, causing corrupted crash path locations? |
It does now, thanks.
This PR turned out to fix an unrelated crash. |
to be honest I dont think my PR should be invalidated until theres a proper fix for the mystery heap overflow. I already did everything I can to debug this. |
There is no mystery. The crash log shows the problem fairly clearly. There are just multiple, unrelated instances of the same issue. In any case, your PR just hides the issue under the rug as I've tried to explain on discord as well. |
So the other PR does fix the underlying issue leading to the heap overflow? |
It seems like the quit dialog gets stuck if you send another sigint while it's open. Otherwise from some quick testing this seems to work as expected 👍 NB: only tested this on tiles |
Thanks for catching that. It should be fixed now. |
I can still reproduce it, eg. on tiles, right on the main menu before loading the game, after two sigints nothing can be selected in the dialog. Also I noticed on the main menu, when selecting No, the game still closes. |
Fixed. I'll leave this in draft for a bit, in case you find other things. Thanks a lot for testing! |
Tested both tiles and curses, seems to work fine now 👍 |
Thanks for merging. |
Summary
None
Purpose of change
Fixes: Fix signal handler #8417
Fixes: Exiting game with CTRL+C leaves console in mouse tracking mode #77011
Closes: avoid crashing on SIGINT by not redrawing the UI #76173
Closes: Reset ImGui and skip restoring curses #77050
these both do similar things in that they try to move execution to a less crashy path before the OS takes over, but don't address the core issue.
Describe the solution
Split SIGINT handling to a separate function
Move all non-
SIG30-C
-compliant code out of the sig handlerAdd a new quit reason (
QUIT_EXIT
) and pass it up to the main loop as an exception, then exit gracefully.Describe alternatives you've considered
Give up on pedantry and just revert #67893 since the old code worked fine and for all edge cases despite being
wrong
.Instead of passing an exception, I could pepper
QUIT_EXIT
checks all over the place.Testing
Send SIGINT or other signals, or try to close the window while playing the game in various states: opening menu, loading files, finalizing data, verifying data, loading save file, waiting for input, doing an activity, and in various UIs. The game should prompt and quit correctly with no crashes.
Additional context
It can take a long time for the prompt to appear during some init stages. More
QUIT_EXIT
checks can be peppered around the code if needed.UIs that don't use a
QUIT
keybinding won't react to SIGINT.There might be other edge cases. Doing it correctly without an unified input loop is hard work.