Skip to content

fix(sandbox): cap the bytes kept from a command's output - #487

Merged
mrnasil merged 2 commits into
mainfrom
fix/sandbox-output-cap
Nov 25, 2026
Merged

mrnasil merged 2 commits into
mainfrom
fix/sandbox-output-cap

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

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.

SharedBuf now 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_cap covers 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

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
mrnasil enabled auto-merge (squash) November 25, 2026 14:49
@mrnasil
mrnasil merged commit 86559dd into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/sandbox-output-cap branch November 25, 2026 20:44
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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.

1 participant