Skip to content

fix(executor): model a pipeline member's spawn failure as a dead child (Refs #3091) - #3720

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3091-pipeline-spawn-failure
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3091-pipeline-spawn-failure

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

GNU forks every pipeline element (execute_cmd.c:2620): when a child's execve fails it reports shell_execve's classified verdict on its own fd 2 (EACCES → 126 "Permission denied", ENOENT → 127 "No such file or directory", execute_cmd.c:6126-6159) and exits; wait_for (jobs.c:3064) records it into PIPESTATUS while the pipeline completes. Rubash's member spawners returned Err and aborted the pipeline — PIPESTATUS came out empty and file_name() dropped the as-typed ./ (findcmd.c:385-387 keeps the attempted pathname for slash-bearing words, the resolved pathname for PATH-found ones).

Every member spawn path now models the failed spawn as a pseudo-member via Vec<Option<Child>>:

  • classified diagnostic + status through member_spawn_failure (shared classifier citing the GNU ownership chain)
  • diagnostic routed through the member's resolved fd-2 plan (piped / null / inherited / direct / ordered-walk files)
  • status lands in its exact PIPESTATUS slot; downstream stdin becomes EOF
  • dev-fd operand records disarmed; job-control waits get projected index-aligned subsets

Paths covered: concurrent all-external spawners (both cfgs), shell-writer/producer-consumer, external-prefix streaming tail, streaming sandwich, and the sequential stage loop (pipeline_stages.rs), where a dead member flags pipeline_stage_spawn_dead so the producer-SIGPIPE verdict applies GNU's race outcome — an in-process builtin's write beats the dead child's exit, an external/function/compound producer's does not.

GNU oracle (WSL Bash 5.3.20, script-file dual-run)

echo hi | fn | ./pnoexec   →  0 141 126   (byte-identical)
cat file | ./pnoexec       →  141 126     (byte-identical)
echo hi | ./pnoexec        →  0 126       (byte-identical)
cat file | ./nosuchfile    →  141/0 127   (GNU is racy; rubash picks modal 141)
printf 100K | ./pnoexec    →  141 126     (byte-identical)

Full probe matrix (first/middle/last member, 2>f, 2>/dev/null, 2>&1, |&, 2>&-, >f 2>&1, merged-stream ordering) byte-identical to /usr/local/bin/bash.

Test plan

  • cargo test --test issue3091_pipeline_spawn_failure_status — 8/8 green (WSL)
  • Adjacent pins green: issue1580, 1363, 1571, 1552, 1540, 0074_1383, 1545, 1807, 1835, 1462
  • cargo check Windows + WSL clean; rustfmt clean
  • CI

Generated with Devin

…d (Refs #3091)

GNU forks every pipeline element (execute_cmd.c:2620): when the
child's execve fails it reports shell_execve's classified verdict
on its own fd 2 (EACCES -> 126 "Permission denied", ENOENT -> 127
"No such file or directory", execute_cmd.c:6126-6159) and exits —
wait_for (jobs.c:3064) records that status into PIPESTATUS while
the rest of the pipeline runs to completion. Rubash's spawners
returned Err on Command::spawn failure, aborting the whole
pipeline: PIPESTATUS came out empty and the member was named by
file_name() which dropped the as-typed "./" (findcmd.c:385-387
keeps the attempted pathname for slash-bearing words, the resolved
pathname for PATH-found ones).

Convert every member spawn to a sparse Vec<Option<Child>>: a failed
spawn becomes a pseudo-member whose classified diagnostic is routed
through the member's resolved fd-2 plan (piped, null, inherited,
direct, ordered-walk files) and whose status occupies its exact
PIPESTATUS slot. Downstream members get an EOF stdin, dev-fd operand
records are disarmed, and job-control waits receive projected
index-aligned subsets. Covered paths: the concurrent all-external
spawners (both cfgs), the shell-writer/producer-consumer route, the
external-prefix streaming tail, the streaming sandwich, and the
sequential stage loop (pipeline_stages.rs), where a dead member also
flags pipeline_stage_spawn_dead so the producer-SIGPIPE verdict
applies GNU's race outcome — an in-process builtin's write beats the
dead child's exit, an external/function/compound producer's does not
(WSL GNU 5.3.20 probe: `echo hi | ./pnoexec` -> `0 126`,
`cat f | ./pnoexec` -> `141 126`, `fn(){cat;} | ./pnoexec` ->
`0 141 126`).

Pin tests/issue3091_pipeline_spawn_failure_status.rs: 8/8 green on
WSL; probe matrix (first/middle/last member, ENOENT/EACCES, 2>f,
2>/dev/null, 2>&1, |&, 2>&-, >f 2>&1, fn sandwich, redirect-ordering)
byte-identical to /usr/local/bin/bash; adjacent pins 1580/1363/1571/
1552/1540/0074-1383/1545/1807/1835/1462 all green.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666
caomengxuan666 merged commit e3a7b7b into master Nov 15, 2026
7 of 11 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/3091-pipeline-spawn-failure branch November 15, 2026 18:29
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
caomengxuan666 added a commit that referenced this pull request Nov 18, 2026
test: land rubash#3550 stale-hash pipeline-member pins (Refs #3550)

Pin-only PR: 11 regression pins for #3550 (stale hashed path in a
pipeline member: wrong ENOENT name, status 0, PIPESTATUS collapse).
No product code changed (single file tests/issue3550_pipeline_spawn_failure.rs,
+338/-0).

Evidence: the three symptoms no longer reproduce on base 58c4cab;
they were fixed by merged PR #3720. The pins pass 11/11 on this
head's census (job 134702174402); fail-first was established by the
lane on the pre-#3720 base (10 red), see ~/workspace/fix-3550/REPORT.md.

Census note: this head's census total is 123, far above the era band
(79-88). The +47 delta vs the pre-burst heads is in parser/quote/
comsub/EOF faces and belongs to the tip base (12-PRs merge burst
08:28-08:36Z), not to this pin-only diff: the pins themselves are
11/11 green and the diff touches no product code. The tip regression
is tracked separately; #3878 was exonerated by its own head census
(79 cells, issue3306 pins 9/9).

本 PR 删除了什么:无(纯新增测试文件)。
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