mobile-shell / mobile-shell/mosh

mosh-server deadlocks on large pastes

Open
#1,356 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
14.5k
Forks
865
PR merge metrics
No merged PRs in 30d

Description

mosh-server deadlocks when pastes >~10KB are pasted into something like vim.

The root cause is the mosh-server calling write into the fakepty master fd with size exceeding the kernel's fd buffer size. Vim stops consuming stdin as it has echoed the large output back to the user in stdout which is not being consumed by mosh-server as it's in a blocking write. So the stdout kernel buffer fills up and now we are in a deadlock.

I have some code that works for me on my fork (https://github.com/mooey5775/mosh/commit/0b53d07d27e1886b5661fc5a902eda7545f20bfd) by adding buffering to the write on the fakepty master fd. It passes all current tests but may be a undesirable as:

  • the buffer is 256 KB
  • the circular buffer is some random implementation, maybe there is something more principled
  • not sure about cross-platform portability?

but if you'd like it as a PR anyways please let me know, I can open one

Contributor guide

No contributing guide indexed for this repository

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 mosh-server fakepty master-fd write path and review the linked fork commit for its buffering approach. Run the current tests, then verify that large pastes into vim no longer deadlock and that the buffering approach works across supported platforms.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.