Skip to content

test: wave-2 pins W2b (Refs #3046, #3089) - #3173

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/W2b-wave1-pins
Nov 9, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/W2b-wave1-pins

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

第二波「钉先行」W2b 组回归钉:修法面被在飞 PR #2968 占着(门控),本 PR 只落钉 + 根因/修法设计(全文在车道 REPORT),门一开修法车道按钉动工。

Refs #3046
Refs #3089

逐单

本 PR 删除了什么

无(纯测试新增)。产品代码零改动。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 9, 2026 06:29
@caomengxuan666
caomengxuan666 merged commit d8f5471 into master Nov 9, 2026
11 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 15, 2026
…IN mirror in exec spawns (Refs #3046) (#3461)

* fix(executor): let a live fd-0 File endpoint outrank the FUNCTION_STDIN mirror in exec spawns (Refs #3046)

Root cause: `exec_inherited_stdin` consulted the FUNCTION_STDIN mirror
before the fd table. The text channel deliberately declines character
devices (shell_options.rs stdin_string_for_command: a device has no
EOF to slurp, "the caller binds the live fd instead"), and
execute_exec's bind_command_fd0_input does bind that live FileFd —
but the mirror arm fired first, so a stage-0 mirror (empty: no
producer) handed the child Stdio::null() (0 bytes), and a later
stage's mirror handed it the upstream pipe bytes (`echo hi | exec dd
</dev/urandom` read "hi\n"), shadowing the redirect the shell had
just bound. A regular file only "worked" because the text channel
slurped its content into the mirror; the child read the mirror, not
the fd.

GNU anchors (vendored bash 5.3.20):
- execute_cmd.c:5520-5522 (execute_subshell_builtin_or_function):
  do_piping first, then do_redirections (redirects, RX_ACTIVE) — the
  element's own redirect replaces the pipe on fd 0.
- execute_cmd.c:6375 do_piping: dup2 (pipe_in, 0).
- builtins/exec.def:231: shell_execve replaces the image with the
  descriptors as bound.
- redir.c:725 redir_open: the target is opened uniformly; the file
  TYPE of the stdin target is never consulted.

Fix: resolve a live fd-table File/CoprocStdout endpoint on slot 0
before the FUNCTION_STDIN mirror — the precedence the codebase
already states in function_stdin_is_command_source ("the mirror is
fd 0's binding only while fd 0 itself is unbound") and in
stdin_string_for_command's tail ("an exec-installed fd 0 in the fd
table shadows the ambient FUNCTION_STDIN buffer"). The bind's text
branch removes the fd-table entry when it stages text, so no stale
File endpoint can coexist with a text mirror from the same bind.

Nails: tests/issue3046_exec_pipeline_chardev_stdin.rs (15 cells,
already on master via #3173) — stdin urandom/head/zero, controls,
stderr devnull/file, subshell, chain, comsub mktemp-style chain,
top-level contrasts, stdout-to-file exception. No new test file.

本 PR 删除了什么:无。仅调整 `exec_inherited_stdin` 内两个分支的
求值顺序(File 臂移至 FUNCTION_STDIN 镜像臂之前),无函数、无文
件、无公开面的增删。

UNVERIFIED-BY-CAPTAIN

* fix(executor): cover the File/CoprocStdout arms in exec_inherited_stdin's endpoint match (Refs #3046)

Rework of f2bae8f: CI was red on a single E0004 (non-exhaustive
patterns) at trap_exec.rs:4538 — the trailing match on
fd_table.read_endpoint(0) had no arms for File / CoprocStdout.
Both arms bind the live fd exactly as the early return above does
(duplicate_handle_inheritable + handle_to_file), the same shape as
open_fd_read_endpoint_stream (shell_options.rs:1182/1194); no
wildcard, no semantic change. GNU anchor unchanged (REPORT §2:
execute_cmd.c:5520-5522, builtins/exec.def:231, redir.c:725).

---------

Co-authored-by: 曹梦轩 <[email protected]>
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