Repository navigation
fix(redir): unify RX_UNDOABLE move verdict across respawn payload faces and async compound roots (Fixes #4046) - #4251
Merged
Conversation
Member
Author
Member
Author
|
CAPTAIN-VERIFY(devin-mac 运行时复验):语义面全证、达合入门附一枚钉的平台稳健化。 已证面:云端真 GNU bash 5.3.20 oracle 14/14 逐字全合(新 face-4 async group 根、r1/r3/c5 全合);双向 fail-first 均成立;issue3932 38/38、issue4028 7/8(唯一红见下)。 唯一未闭项——新钉 裁决:本 PR 代码面可合,但不带一枚在受支持平台确定性红的新钉入主干(会成为新基线红)。请作者把该钉的输出捕获改成平台稳健形(如经临时文件重定向收齐两行诊断再断言,判据断言本身不动),推新 head 后队长按证据沿用直接合入、无需整轮重验。 |
…es and async compound roots (Fixes #4046)
caomengxuan666
force-pushed
the
fix/4046-respawn-compound-rx-undoable
branch
from
November 28, 2026 01:43
cc75a6f to
bcc57ed
Compare
Member
Author
|
Rebased onto
|
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.
Fixes #4046.
GNU C Specification
third_party/bash/execute_cmd.c:1759-1772(execute_in_subshell): for any forked async command (cmd &, simple or compound) or subshell head (( ... ) redirs), the command's owncommand->redirectsrun withRX_ACTIVEonly (noRX_UNDOABLE), soredir.c:1171-1175never runsadd_undo_redirectand emits only the per-redirectionN: Bad file descriptorline (1 line).third_party/bash/execute_cmd.c:854/4268/5606(execute_command_internal): commands executing inside a forked child body —( { true; } ... ) &,{ { true; } ...; } &,<({ true; } ...),>({ true; } ...)— apply redirects withRX_ACTIVE | RX_UNDOABLE, emitting bothredirection error: cannot duplicate fd: Bad file descriptorandline N: 10: Bad file descriptor(2 lines).Root Cause
src/executor/command_input_scope.rs,compound_dup_bad_fdcheckedself.respawn_payload_face.get() == 0whilesrc/executor/redirection.rs(output_walk_is_undoable) checkedrespawn_payload_face.get() != 1. That split suppressed the first diagnostic line for compound commands inside face 2 (( ... ) &) and face 3 (<(...)/>(...)).src/executor/compound_exec/background.rsstamped"compound"whichsrc/executor/init.rsmapped to face0, so an outer async compound command's own redirects ({ true; } 8>/dev/null 8>&10- &) ran as undoable (2 lines) instead of GNU'sRX_ACTIVE-only pass (1 line).#4045is already resolved onmasterafter#4050merged;cat <(ls -1 /proc/$$/fd)now matches GNU 5.3.200 1 2 63 255.)Summary of Changes
src/executor/redirection.rs&src/executor/command_input_scope.rs:Executor::move_walk_is_undoable(&self, cmd: &CommandNode) -> boolused byoutput_walk_is_undoable,compound_dup_bad_fd, andwith_command_input_redirects_scoped.falsefor pipeline/subshell-head/background nodes and respawn faces1(async simple) /4(async compound root); returnstruefor face0(main shell), face2(async subshell body), and face3(procsub body).4inwith_command_input_redirects_innerafter the root's own redirects apply and before the body executes, so{ true; } 8>&10- &emits 1 line while{ { true; } 8>&10-; } &emits 2 lines.src/executor/compound_exec/background.rs,src/executor/init.rs,src/executor/ast_exec.rs,src/executor/mod.rs,src/executor/markers.rs:"compound"to face4u8(stamped only when unconsumed own-redirects replay in the child) and restrictsast_exec.rsnofork arming tomatches!(payload_face, 1..=3).tests/issues_3900_4199/issue4028_move_fd10_bad_fd_diag.rs:tests/issue*.rsbinary per#4210/#4219): async simple/group roots (1 line), nested async group / subshell-body group / subshell-bodyif(2 lines), and input/output procsub bodies (2 lines).What this PR deletes
undoable_walkpredicates incommand_input_scope.rsandredirection.rs(replaced by sharedmove_walk_is_undoable).Verification
/usr/local/bin/bash, script files) — 27/28 shapes byte-identical (sole excluded shape is pre-existingcat <(if...)parser line-3 numbering quirk, separate owner).cargo test --test issues_3900_4199 issue4028— 8/8 passed.cargo test --test issues_3900_4199 issue4028— 8/8 passed;issue3932— 38/38 passed; fullissues_3900_4199sweep — 677/682 passed (the 5 failures are verified pre-existingmaster @ 9f4fc4894behavior).scripts/check-api-ledger.py(298 symbols),scripts/check-marker-literals.py(117 consts), andscripts/check-rustfmt.py(225 targets) all passed.