Repository navigation
fix(executor): stream input process substitutions instead of materializing (#1952) - #1954
Merged
Merged
Conversation
…izing (rubash#1952) GNU process_substitute (subst.c:6362) forks the body onto a pipe and hands the consumer the read end immediately; rubash collected the whole body output in-process (executor/read_io.rs process_substitution_output_bytes_timed) before any consumer bound, so a non-terminating producer starved every consumer (RC audit A-F1: `cat <(echo x; sleep 20)` printed nothing until EOF; `while read … done < <(tail -f …)` never iterated). Route every input-procsub binding site through the real-child spawn the exec form already used (rubash#1021): standalone and command word forms, redirect targets, assignment values, command fd 0 / numbered redirects, and the read builtin's scratch serve; collection stays as the fallback when the spawn cannot be set up. The in-process cat streams a live pipe operand chunk-wise as bytes arrive (GNU cat.c's byte-copy loop over the dup'd descriptor), through one output sink kept to the finish emit. $! names the real producer: `wait` collects its real status, and the boundary reap spends a one-shot bounded grace (5 ms) on streamed producers so `kill -0` is deterministic once EOF was delivered (jobs.c:3064 wait_for reaps while blocked; rubash#1022 parity). Regression pins: tests/regression.rs mod issue_1952 — redirect-loop, cat-argument and pipeline streaming shapes (bounded producer, flag file orders arrival against producer exit), the exec 3< control, and $!/wait/kill -0 parity.
…ildren (rubash#1952) Two serve paths still assumed the collected endpoint kind: - materialize_dev_fd_operands backed only buffered (Text / ProcessSubstitution) endpoints with a fed pipe for external children and skipped File endpoints as "natively resolvable" — but the descriptor lives in this process only, so `$(cat <(…))` and external argv delivery of a streamed word failed ENOENT in the child. Pin a dup of the File endpoint's handle at the operand's number through the same attach machinery (shared offset, not consumed — the GNU fork contract). - The comsub quick-read ladder ($( < /dev/fd/N )) served only the buffered snapshot; a streamed endpoint fell through to an fs read of the literal path. Drain the File endpoint through the shared handle (fd_table::read_file_endpoint_bytes, the &self counterpart of read_all_bytes).
Member
Author
|
Gate results on this branch (Linux, this machine; full detail in the batch report):
Two follow-up commits beyond the first push were needed for external-child delivery of streamed endpoints (materialize attach + comsub quick-read drain) — both are in the branch. |
…ows external-word drain) The pipeline-head streaming pin (issue1952_pipeline_head_streams_first_line) fails deterministically on Windows CI: a process substitution delivered as an argv word to a spawned external child is drained to a temp file before spawn (dev_fd_table_operand File arm -> drain_handle_to_temp), so the consumer cannot see line 1 until the producer exits. Live delivery to external children needs the rendezvous endpoint tracked as rubash#1959 (#1903 / unified-layer S6 design piece); the in-process consumer forms stream on Windows already. Keep the GNU assertion verbatim, add #[ignore] citing #1959 per repo convention; remove the ignore when the #1959 endpoint lands. Root-cause chain: fix-1952 REPORT section 7.
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.
WIP — RC-freeze exception fix for the A-F1 audit finding.
Fixes #1952
Problem
Input process substitution materialized the producer's whole output in-process (
src/executor/read_io.rsprocess_substitution_output_bytes_timed) before any consumer bound, so a non-terminating producer starved every consumer:cat <(echo x; sleep 20)printed nothing until EOF,while read … done < <(tail -f …)never iterated,head -1 <(…) | cathung. GNUprocess_substitute(subst.c:6362) forks the body onto a pipe and hands over the read end at once.Fix (mechanism only)
readbuiltin's scratch serve. Synchronous collection remains as fallback when a spawn cannot be set up.catstreams a live pipe operand chunk-wise as bytes arrive (GNU cat.c byte-copy loop), through a single output sink kept to the finish emit.waitcollects its true status; the boundary reap spends a one-shot bounded grace (5 ms) on streamed producers so `kill -0` is deterministic once EOF was delivered (jobs.c:3064 `wait_for` parity, rubash#1022).Pins
tests/regression.rsmodissue_1952: redirect-loop / cat-argument / pipeline streaming shapes (bounded producer; a flag file orders arrival against producer exit — all three fail on master), theexec 3<control, and ``/wait/`kill -0` parity.Gates (lib baseline name-comparison, full regression, diffcorpus 306, -D warnings check) are being run on this branch; results land in the batch report. Do not merge — CI is the merge gate.