Skip to content

WIP: fix(executor): deliver an ambient /dev/full binding to external children (#2550) - #2555

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/2550-devfull-ambient
Nov 2, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/2550-devfull-ambient

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #2550

Defect

exec 1>/dev/full; /bin/echo hi — the foreign child inherited the HOST stdout: prints hi, rc 0, no diagnostic. GNU bash 5.3.20: the child inherits the opened device, its write fails ENOSPC inside the child (/bin/echo: write error: No space left on device), rc 1.

Root cause

plan_external_stdio declined the whole plan whenever an ambient fd 1/2 binding (or a dup source) was rubash#1898's symbolic FdWriteEndpoint::FullDevice; the legacy routes that take over apply no ambient binding at all, so the binding was silently dropped at spawn.

GNU: a permanent exec redirection installs the OPENED device in the shell's own descriptor table (redir.c:237 do_redirections -> redir.c:790 do_redirection_internal, open at redir.c:725 redir_open) and the forked child inherits that descriptor (execute_cmd.c make_child).

Fix (mechanism, one file: src/executor/external_redirects.rs)

A FullDevice table binding now resolves through full_device_stdio_slot(): a fresh open of the real device where the platform has one (independent open is indistinguishable — the device keeps no offset/state). Both planner sites that resolve table bindings speak it: the fd 1/2 ambient seeding and the dup-source fallback (>&4 after exec 4>/dev/full). Where no kernel device backs the spelling (Windows simulation) or the open fails, the plan declines exactly as before — the #1898 sink contract for in-shell faces is unchanged. The command-local target route is untouched (owned by #2533 / PR #2549).

Verification (build slot + scrubbed_cargo)

  • issue2550_devfull_ambient (new pins, 7 shapes: fd 1, fd 1 append, fd 2, merged 2>&1, fd>=3 dup source, /dev/null + regular-file controls): 7 passed, 0 failed
  • guard issue2483_stream_drain: 6 passed, 0 failed
  • guard issue1496_write_error_diag_regressions: red on base 9348b8d BEFORE and AFTER this change (probe output identical: rc=1/rc2=0/rc3=1) — its failing leg is the command-local face owned by PR WIP: fix #2524 #2533 #2534 #2535 #2549, which is not in this base; expected green once WIP: fix #2524 #2533 #2534 #2535 #2549 lands and this branch is rebased at harvest.

Cluster report: ~/workspace/rubash-wave-20261102/w11-devfull/REPORT.md

…ren (Refs #2550)

plan_external_stdio declined the whole plan whenever an ambient
fd 1/2 binding (or a dup source) was rubash#1898's symbolic
FdWriteEndpoint::FullDevice, and the legacy routes that took over
apply no ambient binding at all — so after `exec 1>/dev/full` a
foreign child inherited the HOST stdout and its writes silently
succeeded (rc 0, no diagnostic).

GNU installs the opened device itself in the shell's descriptor
table for a permanent exec redirection (redir.c:237
do_redirections -> redir.c:790 do_redirection_internal, the open
at redir.c:725 redir_open) and the forked child inherits that
descriptor (execute_cmd.c make_child): the write fails ENOSPC
inside the child, which diagnoses itself and exits 1.

Fix by mechanism: a FullDevice table binding now resolves to a
stdio slot through full_device_stdio_slot() — a fresh open of the
real device where the platform has one (an independent open is
indistinguishable; the device keeps no offset or state). Both
planner sites that resolve table bindings speak it: the fd 1/2
ambient seeding and the dup-source fallback (so `>&4` after
`exec 4>/dev/full` resolves too). Where no kernel device backs
the spelling (Windows simulation) or the open fails, the slot
stays unresolvable and the plan declines exactly as before,
keeping the #1898 sink contract for the in-shell faces. The
command-local target route is untouched (owned by #2533).

Pins: tests/issue2550_devfull_ambient.rs, 7 shapes incl. /dev/null
and regular-file controls — 7/7 green under the scrubbed harness.
Guard issue2483_stream_drain 6/6. Guard
issue1496_write_error_diag_regressions is red on this base before
and after this change (identical probe output): its failing leg
is the command-local face owned by PR #2549, not in base 9348b8d.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 2, 2026 05:35
@caomengxuan666
caomengxuan666 merged commit 31c17d7 into master Nov 2, 2026
11 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member Author

[win-acceptance] #2555 — unix-only face on Windows: the new pin issue2550_devfull_ambient is unix-gated (0 tests on Windows by design; no /dev/full device exists there). Shape recorded only. The touched file src/executor/external_redirects.rs is shared with the #2522 fix whose Windows A/B was verified byte-identical earlier this wave, and the wave-3 combo probes (ambient fd inheritance, write-mode procsub) remain green on the tree containing this merge. No BLOCKER.

Environment: Windows 10 19045 real machine, MSVC Rust debug build of master b41e8b6 (contains this merge), oracle wsl /usr/local/bin/bash 5.3.20.

@caomengxuan666
caomengxuan666 deleted the fix/2550-devfull-ambient branch November 3, 2026 09:07
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