Fix a deadlock on Windows when switching between longer diffs - #5815
Merged
Conversation
winPty.Close could block indefinitely, and it is called while holding the global PtyMutex and while the task's onDone sync.Once is executing, so blocking there wedges the task's entire cleanup chain: the next NewTask call blocks on <-notifyStopped while holding waitingMutex, every later task for that view queues up behind it, and onResize blocks on PtyMutex — a full UI freeze. (Reported by a user via go-deadlock's 30s watchdog; a regression from the ConPTY support introduced for v0.63.0.) ClosePseudoConsole is what blocks; before Windows 11 24H2 it can do so in two ways. It flushes the client's pending output into the out pipe, but a stopped task's scanner goroutine has already quit draining, so with a client that's still producing output the flush never completes; this can also wedge the background waiter's closeHpc, which runs with the pipes deliberately left open. And it waits for the console host to exit, but closing only delivers CTRL_CLOSE_EVENT to the attached client without terminating it, so a client that keeps running (git still computing an expensive diff, a pager waiting for input) keeps the host alive arbitrarily long. Run the teardown on a background goroutine so Close returns immediately no matter which of these strikes, and within it close our pipe ends before the pseudoconsole, without taking p.mu: breaking the pipes fails a pending flush fast, which also unblocks a waiter already stuck in one. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
stefanhaller
added a commit
that referenced
this pull request
Jul 15, 2026
The Windows PTY support that was newly introduced in v0.63.0 had a potential deadlock problem: when switching between longer diffs, lazygit could lock up. This should hopefully be fixed with this PR.
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Jul 17, 2026
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | patch | `v0.63.0` → `v0.63.1` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary> ### [`v0.63.1`](https://github.com/jesseduffield/lazygit/releases/tag/v0.63.1) [Compare Source](jesseduffield/lazygit@v0.63.0...v0.63.1) <!-- Release notes generated using configuration in .github/release.yml at v0.63.1 --> Fixes for a few regressions introduced in the v0.63.0 release. #### What's Changed ##### Fixes 🔧 - Improve index.lock retry mechanism by [@​stefanhaller](https://github.com/stefanhaller) in [#​5788](jesseduffield/lazygit#5788) - Fix userEvents panic by [@​stefanhaller](https://github.com/stefanhaller) in [#​5793](jesseduffield/lazygit#5793) - Fix a deadlock on Windows when switching between longer diffs by [@​stefanhaller](https://github.com/stefanhaller) in [#​5815](jesseduffield/lazygit#5815) ##### Maintenance ⚙️ - Allow releasing from a branch other than master by [@​stefanhaller](https://github.com/stefanhaller) in [#​5819](jesseduffield/lazygit#5819) **Full Changelog**: <jesseduffield/lazygit@v0.63.0...v0.63.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNjMuNiIsInVwZGF0ZWRJblZlciI6IjQzLjI2My42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
1 task
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.
The Windows PTY support that was newly introduced in v0.63.0 had a potential deadlock problem: when switching between longer diffs, lazygit could lock up. This should hopefully be fixed with this PR.