Skip to content

WIP: pipe-diag — pipeline SIGPIPE death, stage diagnostics, timed-read input family (6 fixes) - #1814

Merged
caomengxuan666 merged 7 commits into
masterfrom
fix6/pipe-diag
Oct 27, 2026
Merged

caomengxuan666 merged 7 commits into
masterfrom
fix6/pipe-diag

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Pipeline diagnostics family — six fixes, one commit per issue (baseline f6b5a3f).

Fixes #1580
Fixes #1581
Fixes #1583
Fixes #1571
Fixes #1596
Fixes #1605

What

Verification (2026-10-27, this branch's build)

Known separate divergence (not part of this PR)

Reading from a fifo with a background writer still hangs in rubash where GNU completes — ( printf 'hello\n' > fifo) & + read line < fifo, and the delayed-writer two-read shape, both rc=124 under a 15s timeout vs GNU rc=0. Same stage-input-transport domain, different root; recorded with both sides' shapes for a separate issue.

External children born through the spawn funnel never got the child
signal reset, so pipeline members inherited the executor's
pipeline-period SIGPIPE block (mask survives fork+exec) and exited 1
on EPIPE with leaked diagnostics instead of dying with 141.
Install child_pre_exec_reset at the funnel (external_command_for_named_program),
matching GNU execute_cmd.c:4224 -> trap.c:1489 restore_original_signals.
Regression: tests/issue1580_pipeline_sigpipe_death_regressions.rs
…stdout (#1605)

execute_compound_pipeline_stage / execute_function_pipeline_stage
unconditionally installed an fd-1 capture for the stage body, so an
external command in a final stage resolved /proc/self/fd/1 to a fresh
capture pipe instead of the shell's inherited stdout (residual of
#1454). When the stage is the pipeline's final stage, no capture is
active above it, and the existing final_member_stdout_streams_to_host
predicate passes, skip the stdout capture (stderr capture kept) and
let bytes flow to the real fd 1.
Regression: tests/issue1605_final_compound_stage_stdout_inheritance.rs
…with 2>file (#1571)

For non-first stages, the not-found arm wrote the diagnostic through
the stage's 2>file, but the driver's stream routing then re-opened the
target with truncation and appended the stage's empty captured
stderr, destroying the diagnostic. Mark the stage's fds pre-wired
after the direct write so routing skips it (same mechanism as the
shared-file wiring and the function-stage #412 case).
Regression: tests/issue1571_pipeline_stage_notfound_diag_redirect.rs
…the shell envelope (#1596)

Emulated coreutils (cat/cp/touch) formatted their diagnostics with
the shell's diagnostic_prefix(), wrapping program stderr in a
"script: line N:" envelope GNU never adds — external command stderr
must pass through verbatim (precedent: #1309 cat, #1372 mkdir).
Drop the prefix at the cat closed-stdin and input-is-output sites,
in external_cp, and in external_touch; update the one compat pin
that had baked in the envelope.
Regression: tests/issue1596_external_stderr_no_shell_envelope.rs
…1583)

Investigation on f6b5a3f: input procsub bodies already spawn eagerly
at expansion (bind_input_process_substitution_child, #1021); the
reported lazy start does not reproduce (ps evidence: child present
before any read; body completes after parent exit without a read).
Pin the eager semantics with deterministic discriminators (side
effect visible without consuming input; completion after parent
exit; data-path control).
Regression: tests/issue1583_input_procsub_eager_start.rs
…ut (#1581)

execute_timed_read_pipeline models a literal producer's output as
timing chunks and interprets the consumer body itself: the first
read is computed from the model, and every followup command is then
executed with an EMPTY stdin (timed_read_followup_output passes "").
The modeled bytes beyond the first read's record are never
materialized for the body, so a followup that reads fd 0 — a second
read, mapfile, cat — saw EOF where GNU serves the not-yet-arrived
data (seed: `{ sleep 1; echo A; } | { read -t 0.3 x; read y; }` lost
A). The model is only sound for followups that provably never
consume the stream: gate the followup arm on
timed_followup_keeps_stream (echo/printf/true/:/false/sleep,
assignment-only commands, and followups that rebind their own fd 0);
anything else declines to the sequential stage path, whose
TimedInput judge serves the same body correctly (timeout still
reports 142, late data is served). Diagnosis: instrumented build —
the modeled first read never reaches execute_read, and the second
read observed FUNCTION_STDIN len 0 with no timed input attached.
Regression: tests/issue1581_timed_read_keeps_pending_input.rs
(7 tests incl. mapfile and external-cat followups).
Integrate PR #1814 onto current master for re-gating on the merged
tree. The six per-issue commits are preserved unmodified
(a8463a0 #1580, a24ca53 #1605, 03e4fd8 #1571, 23cf817 #1596,
95995ef #1583, 1156ac7 #1581).

Single conflict, in execute_function_pipeline_stage
(src/executor/pipeline_stages.rs): master added the #1765 tempenv
window (assignments_failed fatal skip + restore_temporary_assignments
after the call); this branch added the #1605 stream_final_stdout
uncaptured branch for a final function stage. Resolution keeps both:
fatal skip first, then the #1605 uncaptured direct call, then the
captured call; the tempenv restore runs after every branch. The
trap-run side kept the branch's stream_final_stdout conditional.
All other overlapping files (path.rs incl. the ms-stopbleed
path_scan_scaffold rework, pipeline_exec.rs, external_file_builtins.rs)
auto-merged; the merged tree's diff against master is exactly the
six commits' 11 files, verified hunk by hunk (#1605 six hunks and
#1571 two hunks in pipeline_stages.rs both present).
@caomengxuan666

Copy link
Copy Markdown
Member Author

集成完成(主会话裁定后推送)

合并 commit 6a954818:普通 merge master a9385b4c 入 fix6/pipe-diag(6 个逐单 commit 未改写)。唯一冲突 src/executor/pipeline_stages.rs 的 execute_function_pipeline_stage 执行段已三支双边保全:① master 的 assignments_failed fatal 跳过优先;② 非 fatal 且 stream_final_stdout 时走 #1605 直调;③ 其余走 master 捕获调用;三支后统一执行 master 的 restore+pop。path.rs / pipeline_exec.rs / external_file_builtins.rs 自动合并并逐点核过;src/lexer/continuation.rs 零改动。合并树 vs master 的净差恰为本 PR 的 11 个文件,#1605 六 hunk 与 #1571 两 hunk 全在。

合并树门(单槽、JOBS=1、净化环境,日志 + .done 实存)

族电池 29/30 的一条 — 主会话裁定(2026-10-27)

issue1605_non_final_group_still_sees_the_pipe 槽内单跑失败 1 次。复核实证:同一失败形状在合并前的原簇二进制上同形同率复现(env-i 条件合并树 1/20 对原簇 2/20;继承 env 9/20 对 5/20;GNU 0/20),钉隔离直跑 6/6 过——这是先存的产品侧时序竞态,非本次合并引入,钉子断言的 GNU 期望正确、不动。裁定:按「失败集与本树基线全等 + 隔离复跑」口径放行本 PR;竞态已独立立案 #1822(归宿:发布后 pipeline/fd 簇,与 #1820 同批),不在本 PR 顺手修。

完整报告:~/workspace/rubash-fix6/clusters/pipe-diag-integ/REPORT-INTEG.md。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 05:17
@caomengxuan666
caomengxuan666 merged commit df848ef into master Oct 27, 2026
8 of 9 checks passed
@caomengxuan666
caomengxuan666 deleted the fix6/pipe-diag branch October 30, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment