Skip to content

Fix deadlock in ttyWriter.Done()#13640

Merged
ndeloof merged 5 commits intodocker:mainfrom
maks2134:fix-ttywriter-deadlock
Mar 18, 2026
Merged

Fix deadlock in ttyWriter.Done()#13640
ndeloof merged 5 commits intodocker:mainfrom
maks2134:fix-ttywriter-deadlock

Conversation

@maks2134
Copy link
Copy Markdown

Resolves race condition between main thread calling Done() and UI thread calling printWithDimensions(). The issue was that Done() held the mutex while sending to the done channel, but the UI thread needed the same mutex to process the done signal.

Fixed by sending the done signal before acquiring the mutex, allowing the UI thread to receive the signal and release any held locks.

Fixes #13639

What I did

Related issue

(not mandatory) A picture of a cute animal, if possible in relation to what you did

@maks2134 maks2134 requested a review from a team as a code owner March 16, 2026 21:16
@maks2134 maks2134 requested review from glours and ndeloof March 16, 2026 21:16
@maks2134 maks2134 force-pushed the fix-ttywriter-deadlock branch from 14acc35 to 2bacf9f Compare March 16, 2026 21:17
Copy link
Copy Markdown
Contributor

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please exclude .idea from git commit (I have this as a global $HOME/.gitignore rule)

@maks2134 maks2134 requested a review from ndeloof March 17, 2026 08:17
@glours
Copy link
Copy Markdown
Contributor

glours commented Mar 17, 2026

@maks2134 can you sign-off your commits please, if you need help just follow this guideline

maks2134 added 2 commits March 17, 2026 11:21
Resolves race condition between main thread calling Done() and UI thread
calling printWithDimensions(). The issue was that Done() held the mutex
while sending to the done channel, but the UI thread needed the same
mutex to process the done signal.

Fixed by sending the done signal before acquiring the mutex, allowing
the UI thread to receive the signal and release any held locks.

Fixes docker#13639

Signed-off-by: maks2134 <[email protected]>
@maks2134 maks2134 force-pushed the fix-ttywriter-deadlock branch from 50518ee to e351d62 Compare March 17, 2026 08:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

maks2134 added 3 commits March 17, 2026 12:09
- Replace context.Background() with context.WithCancel() in test
- Fix formatting issues (remove extra empty line)

Signed-off-by: maks2134 <[email protected]>
- Replace context.Background() with t.Context() in TestDoneDeadlockFix
- Ensures .idea files are not included in commit

Signed-off-by: maks2134 <[email protected]>
Fixes template validation error in CI by updating to latest stable version
of docker/github-builder workflow. This resolves the JToken parsing error
in bake.yml@v1 that was causing bin-image-test to fail.

Signed-off-by: maks2134 <[email protected]>
@ndeloof ndeloof enabled auto-merge (rebase) March 18, 2026 15:09
@ndeloof ndeloof merged commit b043368 into docker:main Mar 18, 2026
39 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 25, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker/compose](https://github.com/docker/compose) | patch | `v5.1.0` → `v5.1.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>docker/compose (docker/compose)</summary>

### [`v5.1.1`](https://github.com/docker/compose/releases/tag/v5.1.1)

[Compare Source](docker/compose@v5.1.0...v5.1.1)

#### What's Changed

##### 🐛 Fixes

- Only pass ConsoleSize to ExecAttach when TTY is enabled by [@&#8203;mikesir87](https://github.com/mikesir87) in [#&#8203;13616](docker/compose#13616)
- Fix deadlock in ttyWriter.Done() by [@&#8203;maks2134](https://github.com/maks2134) in [#&#8203;13640](docker/compose#13640)

##### ⚙️ Dependencies

- update to go1.25.8 by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13622](docker/compose#13622)
- bump github.com/moby/moby/api from 1.53.0 to 1.54.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13619](docker/compose#13619)
- bump golang.org/x/sys from 0.41.0 to 0.42.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13626](docker/compose#13626)
- bump github.com/containerd/containerd/v2 from 2.2.1 to 2.2.2 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13631](docker/compose#13631)
- bump golang.org/x/sync from 0.19.0 to 0.20.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13627](docker/compose#13627)
- bump github.com/moby/moby/client from 0.2.2 to 0.3.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13621](docker/compose#13621)

#### New Contributors

- [@&#8203;maks2134](https://github.com/maks2134) made their first contribution in [#&#8203;13640](docker/compose#13640)

**Full Changelog**: <docker/compose@v5.1.0...v5.1.1>

</details>

---

### Configuration

📅 **Schedule**: 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 [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44Ny4xIiwidXBkYXRlZEluVmVyIjoiNDMuODcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CLI compose up and down hangs with ttyWriter

3 participants