Repository navigation
Disarm the screensaver's signal traps before its cleanup runs - #9166
Closed
omarchybot wants to merge 1 commit into
Closed
omarchybot wants to merge 1 commit into
omarchybot wants to merge 1 commit into
Conversation
exit_screensaver closes the terminal that owns this script's own pty, and bash re-enters a trap for the signal it is already handling, so every hangup that teardown sends back nests the handler one level deeper until the stack is gone. Disarming as the function's first statement is one command too late, because bash can re-enter at the call boundary before the body starts. Driving the real script from a pty on an Omarchy 4.0.1-1 worker under a sustained hangup, eight runs each: the shipped handler segfaulted 8 times, disarming inside the function 2, and disarming as the trap's own first command 0. trap : rather than trap '' because an ignored disposition survives exec, which would leave the hyprctl and pkill children immune to SIGTERM too. Co-Authored-By: Codex GPT-5.6 <codex@openai.com>
Member
|
Automated duplication check: this pull request looks similar to #9042, which covers the same screensaver exit once. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
exit_screensavercloses the terminal that owns this script's own pty, and bash re-enters a trap for the signal it is already handling — SIGWINCH and SIGCHLD have their own machinery, HUP, INT, TERM and QUIT do not — so every hangup arriving while the handler is still running nests it one level deeper. Under a terminal that keeps hanging the pty up, that runs until bash exhausts its stack and dies with SIGSEGV, which is what the cores on #8386 show: the oldest frame iszreadfrom this script'sread -n1 -t 1, thenrun_pending_traps→parse_and_execute→execute_command_internalaround 21,500 times over.The disarm has to be the trap's own first command. At the top of the function it is one command too late, because bash can re-enter at the call boundary before the function body starts. Driving the unmodified script from a real pty on an Omarchy 4.0.1-1 worker (bash 5.3.15-1) under a sustained hangup, eight runs each: the shipped handler segfaulted 8 of 8, disarming as the function's first statement 2 of 8, disarming as the trap's first command 0 of 8 — and 0 of 23 over every run of that shape. The function keeps a disarm of its own so the direct call from the read loop cleans up once rather than twice.
trap :rather thantrap '', because an ignored disposition survivesexec:trap ''would leave thehyprctlandpkillchildren spawned afterwards immune to SIGTERM as well.What this does not do is explain why the reporter's terminal hangs the pty up thousands of times. Nothing in this repository produces that, and the fix does not depend on knowing: the handler is safe at any count.
This touches the same handler as #6813 and conflicts with it textually. That PR's guard — a
shutdownflag andtrap ''insiderequest_shutdown— has the same late-disarm window, and measured the same way it segfaulted 4 of 8 runs, so the disarm still needs to move ahead of the function call if #6813 lands instead.Reviewed by Codex GPT-5.6 at xhigh reasoning, which found the pre-disarm re-entry window independently and is why the disarm moved into the trap string.
Fixes #8386