fix: pick up the ghostty TempDir descriptor-leak fix - #288
Merged
Conversation
Bumps the ghostty pointer by exactly one commit, onto the fork's `fix(os): close the parent directory handle in TempDir`. `TempDir.init` opens two directory handles, one on the directory it creates and one on the system temp directory it creates it in. `deinit` only closed the first, and `Surface.writeScreenFile` guards its cleanup with `errdefer` rather than `defer` (on success the file has to outlive the call, since the path is handed to the pty), so its success path released neither. We call that path every five seconds from `SessionWALStore`'s frame capture, which turned an upstream wart nobody notices into a steady leak: measured live at roughly 600 descriptors held on the temp directory after two hours, growing about one per five seconds toward the process limit. Closes #274.
download-prebuilt-ghosttykit.sh verifies the published xcframework against a checksum pinned per ghostty SHA. A pointer bump without a matching entry falls through to the source-build fallback, which then fails on the runner while linking zig's own build runner against libSystem. The release the Build GhosttyKit workflow published for this SHA exists and is correct; only the pin was missing.
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.
What this does
Stops Programa leaking file descriptors while it runs. Long sessions with agents working in panes were accumulating open handles on the temp directory at roughly one every five seconds, climbing toward the per-process limit. Nothing user-visible until you hit that ceiling, at which point the app can no longer open files or accept connections.
Closes #274.
Summary
Bumps the
ghosttysubmodule by exactly one commit, onto darkroomengineering/ghostty#1.TempDir.initopens two directory handles: one on the directory it creates and one on the system temp directory it creates it in.deinitonly ever closed the first.Surface.writeScreenFilecompounds it by guarding cleanup witherrdeferrather thandefer(on success the file must outlive the call, since the path is handed to the pty), so its success path released neither handle.Upstream never felt this because
write_screen_fileis a keybinding a user presses occasionally. We drive the same action every five seconds fromSessionWALStore's frame capture (frameCaptureCheckInterval), which is what turns it into a steady leak.Evidence
sudo fs_usage -w -f filesys <pid>on a live Release session, one group per ~5 s:lsofconfirmed the growth is entirely TMPDIR-root handles:DIR total 1191 / TMPDIR root 593, and 30 s later1196 / 596. Directory names are 22-char base64 over ghostty's custom-_alphabet andscreen.txtis exactly whatwriteScreenFile'sbufPrintproduces, so the attribution is not circumstantial.Note on the pointer
Deliberately pinned to the fix commit rather than the fork's
main, which is 1782 commits ahead of our current pin. This keeps the change a one-commit delta instead of a wholesale ghostty upgrade. Reconciling those lineages is #185.Test plan
zig build -Demit-xcframework=true -Dxcframework-target=nativesucceeds on the submodule commitghosttypath filter triggerslsof -p <pid> | awk '$5=="DIR"' | grep -c '/T$'stays flat (±2) over 30 minutes of agent activity, where it previously grew about one per five seconds