Guard the @-mention lookup against a disposed shell - #335
Merged
TheGreatAxios merged 2 commits intoAug 7, 2026
Merged
Conversation
Quitting while an @-mention filesystem lookup is in flight let the resolved promise write suggestions into a torn-down shell, touching the freed renderer/TextBuffer. Check shell.disposed after each await in openAtMentionSuggestions and bail before any further write.
attachClipboardImage was the same shape as the mention lookup: it awaits the clipboard read, then unconditionally attaches into shell.pendingAttachments and flashes status. Check shell.disposed right after the await, before any of that runs. This was the third and last await in shell.ts; the other two (both in openAtMentionSuggestions) were already guarded.
TheGreatAxios
deleted the
cl-5554-use-after-free-when-quitting-during-an-mention-lookup
branch
August 7, 2026 06:35
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.
Summary
shell.disposedright after eachawaitinopenAtMentionSuggestionsand inattachClipboardImage— the only two continuations inshell.tsthat resume after an await and then unconditionally write into shell/renderable state — and bail out before any further mutationVerification
shell.tshas exactly threeawaitsites: two inopenAtMentionSuggestions, one inattachClipboardImage. All three now checkshell.disposedbefore touching shell state or renderables.resolves.toBe(false),overlayKind,pendingAttachments). They show the guarded code path is not reached after dispose, which is strong evidence the writes are prevented — but they do not exercise real nativeTextBuffer/renderer memory, so they cannot themselves prove the underlying use-after-free/segfault is impossible. Confidence in the fix rests on the code guard (check-before-mutate at every resume point), not on the test alone.bun run typecheckandbun run buildpass.bun test: 4314 pass, 1 pre-existing failure unrelated to this change (tests/integration/reactor-permission-multi-turn.test.ts, plus twomarkdown-rows.test.tscases in a full run) — reproduces identically on this branch with the fix stashed out, so it predates this work.Closes CL-5554