Skip to content

fix(executor): keep GNU dead-fork shape when a pipeline member's spawn fails - #3607

Closed
caomengxuan666 wants to merge 1 commit into
masterfrom
fix/3550-pipeline-spawn-failure
Closed

caomengxuan666 wants to merge 1 commit into
masterfrom
fix/3550-pipeline-spawn-failure

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Refs #3550. GNU forks every pipeline element (execute_cmd.c:2620), so a member whose execve is refused reports shell_execve's errno on its own fd 2 — naming the resolved PATH spelling — exits 127/126, and keeps its PIPESTATUS slot while neighbours see the dead end's EOF. The concurrent spawn sites instead collapsed the failure into a propagated IoError (mycmd: <posix-msg>), losing the prolog prefix, resolved name, status slot and EOF handoff. Every spawn site (concurrently, spawn_wait, streaming tail, shell-writer, sandwich, sequential stage spawner) now records a virtual member: shared spawn_error_diagnostic + prefix + report_name delivered to the member's own fd-2 surface (ambient live write, dup'd Direct handle, captured pipe result slot / in-order stderr relay, element 2> redirects via deliver_stage_diagnostic), with 127/126 in its results slot. Verified byte-identical vs vendored GNU bash 5.3.20 across 18 faces; 9 new pins.

…n fails (Refs #3550)

GNU forks EVERY pipeline element (execute_cmd.c:2620 execute_pipeline ->
execute_simple_command -> execute_disk_command), so an execve refusal is
reported by the member's own fork on ITS fd 2 — shell_execve names the
execve filename (resolved PATH spelling for searched names,
execute_cmd.c:6143; typed word for slash-bearing names,
findcmd.c:385-387) — and exits 127 on ENOENT else 126
(execute_cmd.c:6126-6159), with the element's own 2> redirects applied
in the fork first (redir.c:237). PIPESTATUS keeps the dead member's
slot and its neighbours see the dead end's EOF.

Every concurrent spawn site previously collapsed the member's spawn
failure into a propagated IoError (`mycmd: <posix-msg>`) that lost the
report_prolog prefix, the resolved-name spelling, the member's status
slot, and the EOF handoff — `hash mycmd; rm bindir/mycmd; mycmd | cat`
printed `case.sh: N: mycmd: ...` and PIPESTATUS `0` instead of GNU's
resolved-path diagnostic and `127 0`.

Each spawn site now records a virtual member: the GNU diagnostic built
through the shared spawn_error_diagnostic + prefix + report_name
construction is delivered to the surface the member's fd 2 was bound to
(ambient stream written live, Direct handles dup'd and written, captured
pipes ride the result slot or relay in member order with the stderr
drains, and the stage spawner routes through the element's own 2>
redirects), and status 127/126 lands in its results/statuses slot.
processes lists carry (member_index, Child) pairs so a dead member's
neighbours keep their pipe ends — dropped handles and an explicit dead
pipe reproduce the dead fork's EOF.

Verified byte-identical against vendored GNU bash 5.3.20 across the
first/middle/last member, shell-writer, streaming-sandwich, member
2>file, member 2>&1, ambient exec 2>&1, comsub capture, brace-group and
! negation faces. Nine new pins in tests/issue3550_pipeline_spawn_failure.rs.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3607 第1轮 — 建议:PENDING(内容未见硬伤;合入阻塞 + Linux 腿在本机跑不到)
head: 1d6060e base(merge-base): 96802ca 文件: 3 个 +997/-253
关联 issue: #3550(状态:open,我核过的时间:2026-11-16 21:1x 本地)

合入阻塞(不合、不关):

机制核查:

  • 方向与 GNU 一致:execute_cmd.c:2620 execute_pipeline 每个元素独立 fork;execve 拒绝由子进程 execute_cmd.c:6126-6159 shell_execve 报 errno(ENOENT→127、其余→126),execute_cmd.c:6143 报的是交给 execve 的解析后路径拼写,slash 形按 findcmd.c:385-387 报词本身;元素的 2> 定向在 fork 内 redir.c:237 先于 execve 生效。
  • 实现读得住:新增 stage_spawn_failure 统一用 spawn_error_diagnostic + error_prefix()/sys_error_prefix() + 解析名/词名,落到元素自己的 fd2(deliver_stage_diagnostic 复刻既有 2>/dev/null/2>file/2>&1 语义并保留 pipeline_stage_fds_pre_wired 防重开);各并发 spawn 位点(concurrently / spawn_wait / streaming tail / shell-writer / sandwich / sequential)把 Err(io::Error) 转成虚拟成员结果槽并保 127/126,PIPESTATUS 槽位与下游 EOF 不被折叠。属机制级修法,不是补丁堆。
  • 风险:单 PR 改动 812 行于仓库最并发的管道执行器,必须由 Linux oracle 腿兜底(见未跑腿)。

腿:

  • 钉自跑(head 1d6060e,Windows):issue3550_pipeline_spawn_failure → test result: ok. 0 passed; 0 failed; 0 ignored。整文件 #![cfg(unix)],Windows 上一个格都不执行,本机无法取到该 PR 的核心证据。
  • fail-first:无法在本机执行(同上,钉全 unix-gated;本机无 Linux rubash 构建)。→ 记 VOID,不记通过。
  • lib 双边(两边先 cargo build --locked --bin rubash):head 1350 passed; 1 failed; 4 ignored / base 1350 passed; 1 failed; 4 ignored;失败名集合都 = {api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell},差集 ∅。
  • 附加回归(Windows,管道面):cargo test --test executor_tests -- --test-threads=2 head vs base 失败名集合逐名相同(45 个基线红名,差集 ∅;target/devin-s9/exec_{head,base}.txt)。未出现本 PR 新增 Windows 红。
  • -D warnings:cargo check --lib 0 警告;cargo check --test issue3550_pipeline_spawn_failure 0 警告。
  • 卫生:cargo fmt --check 受仓库已知 Windows os error 206 限制,改为逐文件 rustfmt --check src/executor/pipeline_exec.rs src/executor/pipeline_stages.rs tests/issue3550_pipeline_spawn_failure.rs → CLEAN;marker-lint OK;utf8 scanned src / clean。
  • CI(head 1d6060e):红 = GNU regression goldens and canaries、Rust tests、Rust tests (macOS);Rust tests 日志红名 = api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell(基线)。该 PR 的 checks 里没有 pin-stem census job(CI: 普查步在 issue2875 转红后永不可达(lib 步先失败即终止 job) #3656 的独立 census 是之后才进 master 的),所以新钉在 Linux 上从未执行过 → 无 Linux 证据。
  • GNU 对照(本机可跑的子集):WSL /usr/local/bin/bash 5.3.20(1)-release(脚本 target/devin-s9/probes/p3550_win.sh)nosuchcmd | cat / echo hi | nosuchcmd / nosuchcmd 2>/dev/null | cat:GNU 分别 127 0 / 0 127 / 127 0 且 stderr 一行 command not found;head rubash 逐字节同(行号、前缀、PIPESTATUS 都对)。但 issue 的核心面是 execve 拒绝(stale hash → ENOENT),Windows spawn 模型无 execve,该面本机不可测。

F 点:无(未发现机制错误;但 Linux 面未验证,不能给 PASS)。

未跑/VOID 的腿:

  • 钉自跑 + fail-first:VOID(整文件 #![cfg(unix)],Windows 0 格执行;需 Linux 构建或队长 Linux oracle)。
  • 18 个 execve 拒绝形状的 GNU 对照:VOID(Windows 无 execve / stale-hash spawn 面)。

处置建议:rebase 解两文件冲突 → 在 Linux(或队长 oracle)上跑 cargo test --test issue3550_pipeline_spawn_failure(9 格)+ base fail-first + 18 形状字节对照,全绿后再合。本轮不合、不关 #3550。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3607 第2轮(T1 收尾)— 建议:FAIL(重复实现:机制已被已合入的 #3720 完全覆盖,本 PR 无增量可合;建议 owner 关闭,非代码缺陷判词)
head: 1d6060e(未变) base(merge-base): 96802ca 文件: 3 个 +997/-253
关联 issue: #3550(状态:open,核于 2026-11-16 22:5x CST)

结论:本 PR 的全部验收面已在 master c3bf91e8(含 #3720 e3a7b7b3a "model a pipeline member's spawn failure as a dead child")上转绿。Unix 腿本轮在 WSL 补齐,证据如下。

证据:

  • 钉自跑(Unix 腿):tests/issue3550_pipeline_spawn_failure.rs(9 个 #![cfg(unix)] 用例)原样拷入 WSL master 构建树 /root/rubash-wsl-t1 @ c3bf91e8(src/ 与 HEAD 零 diff,已核),cargo test --locked --test issue3550_pipeline_spawn_failure → test result: ok. 9 passed; 0 failed。stale_hash_first/middle/last、sandwich_first/last、shell_writer_dead_consumer、member_stderr_merge/redirect/ambient 全绿。
  • GNU 对照:WSL /usr/local/bin/bash = GNU bash 5.3.20(1)-release (x86_64-pc-linux-gnu),脚本文件 D:/repo/rubash-devin-t1/target/devin-t1/probes/issue3550-stale-hash.sh(LF,已存盘)。stale hash 中间成员:GNU 与 rubash master 输出逐字节一致 —— stderr deadcmd: command not found,stdout RIGHT,rc=0 ps=[141 127 0](死成员保槽位 127)。
  • 机制等价:master 侧 member_spawn_failure 覆盖 pipeline_exec.rs 6 个 spawn 位点 + pipeline_stages.rs 1 个(git grep -c 已核),与本 PR stage_spawn_failure 的路由一一对应;issue [bug] Pipeline member with a stale hashed path: wrong ENOENT name, status 0, PIPESTATUS collapses #3550 标题三症状(ENOENT 名、status 0、PIPESTATUS 坍缩)均被钉覆盖且在 master 上复现为 GNU 形状。
  • 冲突面无需再解:git merge-tree --write-tree origin/master 1d6060e8 在 pipeline_exec.rs/pipeline_stages.rs 的冲突正是 fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) #3720 已落地的同一批 spawn 位点;即便机械解完也只会得到与 master 等价的重复实现。

腿:

  • 钉自跑:issue3550_pipeline_spawn_failure 9/9(WSL master 构建,见上)
  • fail-first:不适用——钉在 master 上已绿,证明修复已由 fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) #3720 交付;base(merge-base 96802ca)侧预期红已由第1轮与 PR 描述覆盖
  • lib 双边 / -D warnings / fmt / marker-lint / utf8:无需重跑——本轮零代码改动,结论依据为「钉在 master 上绿」这一充分证据
  • CI:未复核(PR 已无合入价值,CI 红绿不影响判词)

未跑/VOID 的腿:无(Windows 侧 0 格属 cfg(unix) 预期,Unix 腿已补齐)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3607 第3轮(y4)— 建议:关闭(superseded;机制已由已合入的 #3720 完整覆盖,非代码缺陷判词)
head: 1d6060e(未变) base(merge-base): 96802ca 文件: 3 个 +997/-253
关联 issue: #3550(状态:open,核于 2026-11-17 本地)

复核(不接续作、不动分支):

判词:建议 owner 以 superseded 关闭本 PR;issue #3550 是否可关由队长按 #3720 的覆盖度裁定(本 lane 不动 issue)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

评审结论:SKIP — superseded(与已合入的 #3720 重复),不合入,不关闭。

为什么

master 已有 e3a7b7b3a fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) (#3720),与本 PR(Refs #3550)是同一 GNU 语义面:pipeline 元素各自的 fork 中 execve 失败 → 该元素在自己的 fd 2 上报 shell_execve 诊断、退出 127/126、保留自己的 PIPESTATUS 槽,邻居看到 EOF(execute_cmd.c:2620 execute_pipeline / execute_disk_command)。

合并冲突本身也说明了重叠:git merge origin/master 在 src/executor/pipeline_exec.rs 出现 33 处冲突、src/executor/pipeline_stages.rs 3 处——本 PR 重写了全部 spawn 站点(concurrently / spawn_wait / streaming tail / shell-writer / sandwich / sequential),而 master 的 #3720 已在这些同一位置改过。这不是机械冲突。

证据(取 master 侧两个冲突文件,保留本 PR 的 pin 文件)

  • Windows cargo build 绿。
  • Linux cargo build --tests 绿;cargo test --test issue3550_pipeline_spawn_failure(#![cfg(unix)],Windows 上 0 tests)→ 9 passed / 0 failed,即在不含本 PR src 改动的 master 树上,本 PR 的 9 个 pin 全绿:
    stale_hash_first_member_keeps_pipestatus_shape、stale_hash_last_member_keeps_pipestatus_shape、stale_hash_middle_member_reads_eof_downstream、sandwich_pipeline_dead_first_member_keeps_shape、sandwich_pipeline_dead_last_member_keeps_shape、shell_writer_pipeline_dead_consumer_keeps_shape、member_stderr_merge_feeds_the_downstream、member_stderr_redirect_claims_the_diagnostic、ambient_stderr_merge_relays_the_diagnostic_on_stdout。
  • 独立 GNU 5.3.20 对照(probe3607.sh,6 个 shape,master 合并树 vs /usr/local/bin/bash,逐字一致):
    mycmd|cat → st=127,0;cat|mycmd → 0,127;{ mycmd; }|cat → 127,0;mycmd 2>&1|cat → 127,0;mycmd|false|cat → 127,1,0;echo x|mycmd → 0,127,诊断文本同为 <shell>: line 1: mycmd: command not found。

下一步

  1. 若 [bug] Pipeline member with a stale hashed path: wrong ENOENT name, status 0, PIPESTATUS collapses #3550 还有 fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) #3720 未覆盖的格子(例如本 PR 特有的「sandwich」元素 2> 重定向投递、in-order stderr relay),请基于 master 现状提最小增量 PR 并附 fail-first;本 PR 的 pin 文件可直接复用。
  2. 不要把本 PR 整棵 pipeline_exec.rs 重写再贴回:master 该文件在 fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) #3720 之后还有 fix(executor): resolve sequential 2>&1 against the dup-time snapshot (Refs #3403) #3631/fix(executor): dup-save procsub spawn-plan fds before the plan bind retires them (Refs #3732) #3741/executor: port GNU async-stdin verdict to pipe-fed pipeline elements #3734/fix(executor): pipeline-element prefix assignment ignores fatal arithmetic error (#3456) #3760 等改动,整体替换会回退这些修复。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3607 第4轮 — 建议:关闭(superseded;机制已由已合入的 #3720 完整覆盖,非代码缺陷判词)
head: 1d6060e(未变)base(merge-base): 96802ca 文件: 3 个 +997/-253
关联 issue: #3550(状态:open,核于 2026-11-17 17:5x +08)

复核(不接续作、不动分支):

  • git merge-base --is-ancestor e3a7b7b3a origin/master → YES:fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) #3720 "model a pipeline member's spawn failure as a dead child" 仍在当前 master ccb86141 历史中。
  • 第 2/3 轮 Unix 腿证据仍然有效:钉 tests/issue3550_pipeline_spawn_failure.rs 9 个 #![cfg(unix)] 用例在 WSL master 构建树上 9/9 绿;stale-hash 中间成员 GNU 5.3.20(1) 与 rubash master 输出逐字节一致(stderr deadcmd: command not found、stdout/PIPESTATUS 形状全等)。
  • head 未推进、无新实质评论;mergeable 仍为 CONFLICTING(master 侧 pipeline_exec.rs/pipeline_stages.rs 已多处演进,与第 1 轮记录一致)。

建议 owner 关闭本 PR(与已合入 #3720 重复实现);issue #3550 是否可关由队长按 #3720 覆盖面裁定(本 lane 不关单、不合并)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
e2 批次汇总(5 条返工/复核,2026-11-17)

PR 建议判词 要点
#3607 建议关闭(superseded) #3720 仍在 master;机制全覆盖,非缺陷判词
#3652 建议 PASS 新 merge head 96dcd34 语义解法实测成立:WSL 钉 5/5、fail-first 3 红、lib 1273/0;CI 红全归因(stale-base hygiene + coproc flake + 基线)
#3685 建议 PENDING 内容腿沿用前轮全绿;仍 CONFLICT(mapfile_helpers.rs 语义冲突),需作者按 master StagedText 架构重做合并
#3701 建议 FAIL(维持) 退出码半边反 GNU 须整段回退;ANSI-C 半边 12 探针实证正确但裸 $(...) 形状硬依赖 continuation.rs 两 hunk(本 lane 不可动),仅落非 continuation.rs 部分 = 半成品;另报 master 相邻残差(word-EOF 不保留前值非零)
#3744 建议 FAIL(需返工) 决策=合钉:钉文件 5/8 格对 master 有净增量,按队长口径 rebase 为只留钉;本 lane 无权推非 draft 外部分支

阻塞项:#3685 等作者 rebase;#3701 ANSI-C 半边等队长处置 continuation.rs;#3744 等作者/队长执行 pins-only rebase;#3652 CI hygiene 红需下次 update-branch 消 stale-base。
终报:D:/repo/rubash/target/devin-dispatch/final-report-e2.md

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】superseded 建议关闭

f3 车道复核(2026-11-17 20:0x +08,master a41909d):

建议:owner 关闭本 PR(superseded,非代码缺陷判词)。若 #3550 尚有 #3720 未覆盖的格子(如 sandwich 2> 投递、in-order stderr relay 的残余形状),请基于 master 现状提最小增量 PR 并附 fail-first;本 PR 的 pin 文件可直接复用。
(agent 不关 PR,只给建议。)

caomengxuan666 added a commit that referenced this pull request Nov 18, 2026
The stale-hash pipeline-member mechanism (wrong ENOENT name, status 0,
PIPESTATUS collapse) is already fixed at this base by merged #3720
(e3a7b7b, model a pipeline member's spawn failure as a dead child,
Refs #3091): the issue repro runs GNU-identical on the base Linux
build and this nail is green on the base. This commit lands only the
regression pin so #3550 can close with evidence.

Nail provenance: tests 1-9 adopted verbatim from PR #3607's
tests/issue3550_pipeline_spawn_failure.rs (closed unmerged as a
duplicate of #3720; its 9 tests were verified 9/9 on master c3bf91e
in that PR's round-2 audit but never landed). Tests 10-11 are this
lane's additions (plain-command control, explicit PIPESTATUS
slot-count lock).

GNU anchors: execute_cmd.c:2620 execute_pipeline (each element via
execute_simple_command -> execute_disk_command); execute_cmd.c:6143
shell_execve names the search_for_command result; execute_cmd.c:6126-6159
ENOENT -> 127. Expectations are GNU bash 5.3.20 outputs, re-verified
with the vendored 5.3.20 oracle.

UNVERIFIED-BY-CAPTAIN
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