github / github/app

Terminal canvas: concurrent send_terminal_input calls race and corrupt PTY input (intermittent binary garbage)

Open
#3,781 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
2.1k
Forks
157
PR merge metrics
No merged PRs in 30d

Description

Summary

When multiple send_terminal_input actions are delivered to a Terminal canvas in rapid succession (e.g. an agent emitting them as parallel tool calls in one turn), the writes are not serialized at the PTY layer. The byte streams interleave, producing corrupted terminal input. In mild cases commands collide/jumble; in severe cases the terminal receives uninitialized/stale memory bytes as input.

Observed (severe form)

Garbage typed into the shell, e.g.:

> X?op?op??%?*bX?
X?op?op??%?*bX?: The term 'X?op?op??%?*bX?' is not recognized...
> ??op4h}0?op??? ?op@?H?op^C

? = invalid UTF-8 bytes; repeating op + control bytes look like buffer/memory garbage; trailing ^C is the shell aborting the mangled line.

Reproduction (mild form, reliable)
  1. Open a Terminal canvas (pwsh on macOS).
  2. Issue several send_terminal_input calls back-to-back with no read/wait between them (e.g. echo A, echo B, echo C, then Up-arrow \u001b[A, then Enter \r).
  3. Read output — commands are dropped/interleaved:
> echo canvas-test-1echo C
canvas-test-1echo
C

Single sends (one call, wait, read) are always clean.

Environment
  • macOS, shell = PowerShell 7.6.0 (pwsh)
  • GitHub Copilot desktop app, Terminal canvas
  • CLI version 1.0.84-4
Expected

Concurrent/rapid send_terminal_input writes should be queued and serialized (or the write buffer locked) so input can never interleave or emit uninitialized bytes. A write should only ever contain the exact input bytes provided.

Impact

Corrupted commands run in the user's real shell; the garbage variant is alarming and can, in principle, execute unintended input.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Terminal canvas send_terminal_input entry point and reproduce the issue with several back-to-back calls, then trace the PTY write path. Done means concurrent inputs are queued or serialized so each write contains only its provided bytes; verify the reproduction no longer interleaves commands or emits garbage.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli, desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.