Repository navigation
fix(sandbox): cap the bytes kept from a command's output - #487
Merged
Merged
Conversation
The pipe readers appended every byte to an unbounded Vec. A command that never stops printing (`yes`, a runaway loop) grew it until the timeout or until memory ran out, and the result was then cut down downstream anyway. Keep at most 8 MiB per pipe: the first half and the last half, with a note saying how many bytes in between were dropped. The reader still drains the pipe, so the child never blocks on a full pipe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
enabled auto-merge (squash)
November 25, 2026 14:49
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The sandbox pipe readers appended every byte to an unbounded
Vec. A command that never stops printing (yes, a runaway loop) grew that buffer until the timeout fired or memory ran out. The result was then truncated downstream anyway.SharedBufnow keeps at most 8 MiB per pipe: the first half and the last half, with[N bytes of output dropped]between them. The reader still drains the whole pipe, so the child never blocks on a full pipe.Test:
shared_buf_keeps_head_and_tail_past_the_capcovers three cases with a small cap: a write that fits, a single write larger than the tail, and small writes that roll the tail.🤖 Generated with Claude Code