Repository navigation
WIP: fix(#1968 pins, #1902): builtin-route fd facts — residual input-redirect pins + test -w /dev/stdin follows the bound fd - #2088
Merged
Conversation
rubash#1968's suppression fix landed in #2051 (buffered builtin route settles registry-class input redirects before writing; #2015 settled the fd-alias shapes). The issue's follow-up names the representative builtins "echo/read 等" — this pins the faces #2051 did not cover: read (input + readwrite), `:`, and the external `true` face, each asserting rc=1, the named-target diagnostic, and no output, plus the read-through-open control. GNU model: do_redirections runs before every command body (execute_cmd.c:5606 execute_builtin_or_function); a failed open is a redirection_error (redir.c:149-176) — the command does not run. Verified byte-for-byte against WSL GNU bash 5.3.20 via script file (probe and raw A/B output under D:/repo/nbbuild/pkg10/E/artifacts/). fmt disclosure: committed with --no-verify because the hook's bare `cargo fmt --check` fails with Windows os error 206 (command line too long) on this box for BOTH this tree and the pristine base (verified); every changed file passes `rustfmt --edition 2021 --check` explicitly. Fixes #1968
…ants virtual_device_test answered /dev/stdin, /dev/stdout, /dev/stderr and /dev/fd/N from constant tables: `test -w /dev/stdin` was false even with fd 0 bound to a writable file, `test -c /dev/stdin` true even with fd 0 bound to a regular file, `test -e /dev/fd/3` false for any bound fd. GNU source: test.c unary_test (test.c:544) hands the word to sh_stat/sh_eaccess; sh_eaccess routes path_is_devfd operands (eaccess.c:63-77) through sh_stataccess (eaccess.c:116), whose sh_stat (eaccess.c:80) fstats the CURRENTLY BOUND descriptor and checks the mode bits of what it found — the answer follows the binding, never the spelling. Change: the executor mirrors its fd table into __RUBASH_FD_TARGET_<fd> (a File-bound fd's target path — every file predicate answers from the referent, the procfs-symlink semantics, alias chains included, cycle guarded) and __RUBASH_FD_ACCESS_<fd> (device class + mode bits for every other open endpoint: fifo/console/directory/null-char/generic-file; an empty tombstone for entries the shell closed — the /proc/self/fd/N ENOENT face). DOS device binds (NUL, CONIN$) are judged by the stored file NAME —the bind records a cwd-joined name that metadata() cannot resolve. The streaming pipeline tail's consumer pipe is fd 0's truth while armed (rubash#761) unless the stage re-binds fd 0 itself. builtins/test.rs resolves the alias through the marks (fd_alias_fact_test) before the constant tables, which survive only as the un-synced fallback (source/ upstream harness bridges with no executor context). String/option/ variable ops stay literal; -h/-L answer the procfs-symlink node (the probe-verified rubash#545 verdict). Gated by the same fused operand scan that already drove the pipe marks (stdio spellings and /proc/<ownpid>/ fd/N join the operand set); [[ ]] file unaries sync through conditional_file_unary. Pins: tests/issue1902_fd_alias_fact_regressions.rs (8) — every face hand-measured against WSL GNU bash 5.3.20 (mode-bit faces measured as a dedicated uid-1000 account, since root's W_OK is unconditional); raw oracles under D:/repo/nbbuild/pkg10/E/artifacts/fix1902/ (gnu-nobody.txt vs rubash-before.txt vs rubash-after.txt). Known residuals (pre-existing, pristine-identical at 03ae580, outside this issue): the Windows emulated store's chmod-read-only and x-bit emulation — the direct-path face and the fd-alias face answer identically, which is the contract here; `exec 0</dev/null` swallows a subsequent compound pipeline stage's stdin (probe6, also broken before this change); the #1968 /dev/tcp loopback pins cannot connect in this sandbox (fail identically on pristine). fmt disclosure: committed with --no-verify — the hook's bare `cargo fmt --check` fails with Windows os error 206 on BOTH this tree and the pristine base (verified); every changed file passes `rustfmt --edition 2021 --check` explicitly. Fixes #1902
Member
Author
|
主会话评审(2026-10-29):本 PR 当前全 CI 红,根因为 PR 自身编译缺件,证据如下:
|
# Conflicts: # src/executor/command_dispatch_late.rs # src/executor/types.rs
…nce) The #1902 fd-alias facts call crate::fd::is_dos_device_path from sync_fd_alias_facts without a platform gate; the helper lived only in windows_impl, so every non-Windows target failed E0425. Add the always-false stub mirror to src/fd/unix.rs (the executor wrapper documents the same 'always false off Windows' contract), restoring the crate::fd root surface on unix targets.
…h#1902 x #2042) Master's #2042 added FdWriteEndpoint::ProcContentWrite after this branch forked; the #1902 write-endpoint classification match had no arm for it (E0004 at the takeover merge). A ProcContentWrite bind is a 0644-class synthetic /proc regular file: generic-file class, readable by inode mode, writable — mirroring the FD_FILE_PREFIX measurement. A class the read side already settled stands.
Member
Author
主会话接管收敛(2026-10-29,用户指派):已合 master + 修 E0425,内容已审,余两项裁定项按退回意见处理完毕,head
内容已审(#1902 的 marks 机制 + #1968 钉):设计与注册表/marks 架构一致、无逐名特判,审读通过。余两项待主会话裁定(全文见接管 REPORT):
CI 全绿前不合;A/B 裁定后按裁定走。 |
…, PR #2088 §A) GNU test.c:544 unary_test -> lib/sh/eaccess.c:63-77 sh_eaccess -> eaccess.c:116 sh_stataccess: an fd-alias operand answers from the CURRENTLY BOUND descriptor. The #1902 marks sync classified only fd-table entries, and two binding shapes never reach it: 1. Pipeline stages. execute_pipeline_stage / execute_lastpipe_stage clear the fd-table slot for the staged FUNCTION_STDIN mirror's duration (the mirror governs the stage's reads), so a stage's fd 0 produced no marks at all and `[ -p /dev/stdin ]` inside a stage answered from the shell's own descriptors. The stage funnels now install FD0_STAGE_PIPE beside the mirror (execute_cmd.c:2620 execute_pipeline + do_piping, execute_cmd.c:6373: the element's fd 0 IS the pipe), saved/restored with the mirror and inherited verbatim by stage clones through env_vars; sync_fd_alias_facts turns it into the fd-0 `prw` mark only when no fd-table entry spoke for fd 0 and the command carries no descriptor-class fd-0 redirect winner. A command-scoped mirror rebind (bind_command_fd0_input's text branch, the flat-subshell region feed) supersedes the fact for its scope unless its own source is a pipe in GNU (heredoc / here-string / procsub), via the shared fd0_mirror_binding_keeps_pipe_fact judgment and the guard's save/restore. 2. Procsub-bound stdin. An `exec 0< <(...)`-family bind installs a File endpoint whose stored path is the `<(source)` carrier spelling (spawn_input_process_substitution_child, subst.c:6362); the sync emitted that spelling as FD_TARGET and the evaluator re-entered on it as a filesystem path, so every predicate failed. The spelling is transport, not a path: a File endpoint carrying it over a pipe handle is now classified as the pipe it is (class p), in both the read and write arms — the same judgment initial_pipeline_input documents for its stage-0 alias fold. Verification (pins run OUTSIDE the build slot, fd 9 unheld): issue1902 pins 8/8 (was 7/8); issue1968 pins 11/14 with the three red exactly the /dev/tcp trio owned by rubash#2124 on master. Adjacent faces green: 1467, 1898, 2029, 2030, 2042-filefd, 2103, 2111, 2053, 2057. Baseline-binary A/B (stash build) confirms the guard shapes changed only where §A intends: a stage group's own /dev/null bind no longer inherits the pipe fact, and the simple element's own `< file` face is byte-identical to baseline (a separate pre-existing sync-ordering gap, recorded in the takeover REPORT §A-fix).
This was referenced Oct 29, 2026
…direct guard site The update-branch merge with master brought in the #2124 net-redirect branch of bind_command_fd0_input, whose CommandFd0InputGuard initializer predates this branch's saved_stage_pipe_fact field (E0063 on the cross-target checks). The net branch does not touch FD0_STAGE_PIPE, so the guard saves and restores exactly the fact it found — the same save/restore-parity shape as the compound-stream branch. No behavior change relative to either parent.
…lass byte The UTF-8 boundary hygiene gate flags `bits.as_bytes()[0] as char` in the fd-fact face of eval_unary. `bits` is an engine-minted ASCII access mark (device-class letter + rwx flags), so byte 0 is always < 0x80 and never a UTF-8 continuation byte; widen through char::from with the justification recorded at the site, per the gate's sanctioned shape.
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 draft — first commit pushed for early review; the #1902 fix commit follows.
Commit 1 — Fixes #1968 (pins only; suppression itself landed in #2051)
Residual regression pins for the faces #2051 did not cover:
read(input +<>),:, externaltrue× bad fd — rc=1, named-target diagnostic, no output. A/B vs WSL GNU bash 5.3.20 byte-identical (probe: pkg10/E/artifacts/p1968.sh).Commit 2 — Fixes #1902 (following)
virtual_device_test answered the fd aliases from constant tables; GNU answers from the BOUND fd (sh_eaccess eaccess.c:63-77 → sh_stataccess eaccess.c:116 → sh_stat fstat, eaccess.c:80). Executor mirrors the fd table into
__RUBASH_FD_TARGET_<fd>/__RUBASH_FD_ACCESS_<fd>; the evaluator resolves the alias through the marks.fmt disclosure
Commits use --no-verify: the hook's bare
cargo fmt --checkfails with Windows os error 206 (command line too long) on BOTH this tree and the pristine base (verified); every changed file passesrustfmt --edition 2021 --checkexplicitly.Never self-merge. Branch base: origin/master 03ae580.