Repository navigation
test: wave-2 pins W2b (Refs #3046, #3089) - #3173
Merged
Merged
Conversation
caomengxuan666
marked this pull request as ready for review
November 9, 2026 06:29
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]>
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.
第二波「钉先行」W2b 组回归钉:修法面被在飞 PR #2968 占着(门控),本 PR 只落钉 + 根因/修法设计(全文在车道 REPORT),门一开修法车道按钉动工。
Refs #3046
Refs #3089
逐单
tests/issue3046_exec_pipeline_chardev_stdin.rs,15 格。管道/子 shell 位exec的 stdin 字符设备绑定塌成 EOF、stderr 重定向被丢弃;含无 exec/普通文件//dev/null 对照、顶层对照、mktemp 式三级 exec 链(生产死亡形)。GNU 锚点:execute_cmd.c:1576 execute_in_subshell、execute_cmd.c:5522 do_redirections、builtins/exec.def:231 shell_execve;期望值逐字节取自 GNU bash 5.3.20 探针。tests/issue3089_redirect_target_quoted_space_join.rs(随后续提交追加)。重定向目标「引号空格段 + 替换段」拼接误报 ambiguous redirect;含真 ambiguous 三形负对照(GNU 同报,防全放行)。GNU 锚点:redir.c:298 redirection_expand 的字段计数语义。本 PR 删除了什么
无(纯测试新增)。产品代码零改动。