Skip to content

Fix a deadlock on Windows when switching between longer diffs - #5815

Merged
stefanhaller merged 1 commit into
v0.63.1from
fix-windows-deadlock
Jul 15, 2026
Merged

Fix a deadlock on Windows when switching between longer diffs#5815
stefanhaller merged 1 commit into
v0.63.1from
fix-windows-deadlock

Conversation

@stefanhaller

Copy link
Copy Markdown
Collaborator

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.

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 stefanhaller added the bug Something isn't working label Jul 15, 2026
@stefanhaller
stefanhaller merged commit f170823 into v0.63.1 Jul 15, 2026
13 checks passed
@stefanhaller
stefanhaller deleted the fix-windows-deadlock branch July 15, 2026 08:24
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 [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5788](jesseduffield/lazygit#5788)
- Fix userEvents panic by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5793](jesseduffield/lazygit#5793)
- Fix a deadlock on Windows when switching between longer diffs by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5815](jesseduffield/lazygit#5815)

##### Maintenance ⚙️

- Allow releasing from a branch other than master by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;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=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant