You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] A pipeline hangs forever, past the timeout, when a later stage writes more than 64 stderr lines without reading stdin #366
Same as bash: 65 rm errors on stderr, then rc=1, straight away.
Actual Behavior
No output, and the shell never returns. I killed it after 10 s (it was using a full CPU). With [limits] timeout = 2 in the config it still ran until I killed it at 10 s; the same config stops sleep 100 after 2 s.
The threshold is exact: with 64 operands instead of 65 the script prints the errors and rc=1 at once.
Additional Context
Found while reviewing #354. On main I reproduced it with rm, which reports each failing operand and keeps going; I did not look for other commands that can write that many stderr lines. #354 makes cat and mkdir do the same, so grep line lines | mkdir $a and grep line lines | cat $a (same script, 65 failing operands) return on main and hang on that PR's head 4946e4b. The rest of the #335 follow-ups (tee, rmdir, chmod, cp, sed -i, wc) will reach it the same way.
It needs all three: the command is not the first stage, it writes 65 or more separate stderr lines, and the stage before it writes 65 or more chunks that nobody reads. A subagent that ran more shapes for the #354 review reported no hang when stderr is redirected (2>/dev/null, 2>file), when the command is the first stage, or when it sits inside { }, ( ), a function or a while; I did not re-run those.
Possible Solution
Read from the code, not confirmed with a debugger:
Each stage gets a 64-slot stderr channel (src/exec.rs:4163), and one task drains those channels in stage order (src/exec.rs:4401-4406), so stage 2's channel is not read until stage 1 has finished.
Stage 1 can't finish: its 64-slot stdout pipe (src/exec.rs:4147) is full and stage 2 never reads it.
Stage 2 then fills its stderr channel, and the write retries in a busy loop (src/os.rs:1266-1270), which would explain the CPU use.
Draining every stage's stderr concurrently would break the cycle. I have not looked at why the timeout does not fire. I have not written or tested a fix.
Activity