microsoft / microsoft/terminal

Deadlock when pasting >5 KiB into an application that doesn't read it fast enough

Open
#17,384 7 comments 0 reactions 0 assignees View on GitHub
Area-TerminalConnection Issue-Bug Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.20.11381.0

### Windows build number

10.0.19045.4412

### Other Software

WSL

### Steps to reproduce

1. Open a WSL tab under Windows Terminal (I've reproduced with Ubuntu 20.04 and RHEL 7 distros, though I assume this bug is independent of the chosen distro)
2. Paste this command to your shell, but don't run it yet:
`python3 -c 'print("Paste now:"); import time; time.sleep(10)'`
3. Copy [the text of Frankenstein](https://raw.githubusercontent.com/asweigart/codebreaker/master/frankenstein.txt) to your clipboard
4. Run the `python3` command you pasted in step 2.
5. When the "Paste now:" message appears, paste the text of Frankenstein to your terminal, and say "paste anyway" at the dialog box.
6. The terminal deadlocks. The first 4096 bytes of Frankenstein appear in the terminal. It is no longer possible to Ctrl-C the python3 script.

### Expected Behavior

The terminal should remain responsive. Ctrl-C should work. The full pasted text should be displayed.

### Actual Behavior

Deadlock. I assume that what's happening here is that Windows Terminal is making blocking write() calls in its paste implementation. If the application doesn't read what's been pasted, or can't keep up, the terminal hangs and becomes totally unresponsive. This was discovered while investigating [an issue with the Python 3.13 REPL](https://github.com/python/cpython/issues/119517), but it appears to be a bug in Windows Terminal itself.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the deadlock with a WSL tab, the provided Python command, and the Frankenstein text. Inspect Windows Terminal's paste implementation and the path handling pasted input when the application reads slowly. Done means the terminal stays responsive, Ctrl-C works, and the full pasted text is displayed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.