fix(interp): report write errors on builtin stdout instead of exiting 0 #708
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 248 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.330
Real PR Conversation Timeline
1 comments
"Review active on #708"
general
weight: 0.35
louis-cqrl
What
CallContext.Out/Outfdrop the error from the underlying write, and the dispatcher only looked at the builtin's own return code. Soecho,printf,sed,awk,sort,grep,cut,wc,ls,find,stringsandsha256sumexited 0 on ENOSPC/EIO/EFBIG and left a truncated redirect target.The dispatcher now wraps the builtin's stdout in a
builtins.WriteGuard, which remembers the first write error and fails every later write with it:<cmd>: write error: <reason>line and sets the status to 1, as bash does (e.g.echo: write error: no space left on device; lowercase like rshell's other messages andtr's existing write error).cat,head,uniq) aren't reported twice.find -exec/xargschild dispatch gets the same treatment.Credit
Found by Jacob Hayes with his deterministic-simulation tool patina (finding #1: SILENT oracle, random EIO leg, about 25k runs; reproduces natively with RLIMIT_FSIZE). Findings thread: https://dd.slack.com/archives/D0AC8RLB21J/p1793475631273749
Tests
interp/builtin_write_error_test.gogives the runner a stdout that fails with ENOSPC:TestBuiltinWriteErrorReported: echo, printf, sed, sort, grep, wc, cut, cat, head and uniq each exit 1 with exactly one stderr line.TestBuiltinWriteErrorFormat: the exact echo message.TestBuiltinWriteErrorBrokenPipeSilent: EPIPE prints nothing.The first two fail on main for the Out-based builtins.
go test ./...passes exceptTestPSPentestLargePIDListDoesNotHanginbuiltins/ps, which fails the same way on clean main on this host (it has real processes with the PIDs the test assumes are missing).🤖 Generated with Claude Code