Repository navigation
executor: transport CMD_IGNORE_RETURN through coproc/async respawns and comsub - #3743
Conversation
…nd comsub
exec16.sub: `! coproc CP { set -e; false; echo reached; }` never
printed `reached` — GNU runs the flagged coproc body in a real fork
where the node's CMD_IGNORE_RETURN flag carries by inheritance
(execute_cmd.c:2546 execute_coproc -> execute_in_subshell,
execute_cmd.c:1576's subshell fork), but rubash respawns the body in
a fresh `rubash -c` process that seeds suppress_errexit = 0. The same
leak applied to trailing `&` async wrappers
(execute_background_ast_command).
Fix 1: a `__RUBASH_SUPPRESS_ERREXIT` env stamp on the respawn env map
brackets the boundary — init.rs consumes it into the child Executor's
suppress_errexit = 1. Procsub spawns are deliberately NOT stamped:
subst.c:6362 builds procsub children without the flag path, verified
(`! cat < <(set -e;false;echo x)` prints nothing under GNU 5.3.20).
Fix 2: GNU's comsub_ignore_return counter (execute_cmd.c:252) was
missing entirely. It is raised around expand_words of a
CMD_IGNORE_RETURN-flagged simple command (execute_cmd.c:4616) and a
flagged `[[ ]]`'s operands (execute_cmd.c:4012/:4060/:4067), and
builtins/evalstring.c:496 stamps CMD_IGNORE_RETURN on every command
a comsub's parse_and_execute yields while the counter is held — so
`! x=$(set -e; false; echo cs)` assigns cs, `if z=$(...)` assigns
ifz, `! f` exempts the function body's `x=$(...)`. Ported as
Executor.comsub_ignore_return, raised around expand_command_words
(command_execute), the pure-assignment RHS loop
(execute_empty_words_command — bypasses expand_command_words), and
expand_conditional_word; the comsub boundary now clears
suppress_errexit only when the counter is zero (subst.c:7023-7029
errexit env/errexit_ignore_frame clears unchanged).
Verified byte-identical vs GNU bash 5.3.20 across invert/if/while/
until coproc, async `&`, eval/group/function-body comsubs, plain
coproc/comsub/procsub non-exemption; exec16.sub byte-identical.
Refs #3605
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
队长 FAIL:自家面测试红。CI run 43748436648 上 |
The env_namespace_census_is_complete test scans src/ for __RUBASH_* tokens and requires every one to be censused; SUPPRESS_ERREXIT_TRANSPORT added the key without an EXACT entry, turning the census test red on CI. Refs #3605 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
确认。census 漏登 |
|
队长跟进:新头 c48b8a8 的 census 红已解除,FAIL 撤销。
本 PR 转入 Windows agent Wave 2:钉 fail-first + 全绿、邻居、lib 双边、 |
|
【WIN-AGENT-AUDIT】PR #3743 第2轮 — 建议:PASS 机制核查:
腿(逐项给数字与名字):
F 点:无 续作记录(本轮动过代码):
未跑/VOID 的腿:无 已知残余(PR 正文自述,出界、不影响本单): 合并处置:head 与审计时点一致、MERGEABLE,已 squash 合入;#3605 为伞目录 issue,按台账铁律不关单。 |
Summary
Two missing halves of GNU's
CMD_IGNORE_RETURNmodel, root-caused offexec16.sub(! coproc CP { set -e; false; echo reached; }never printed its marker):coproc / trailing
&respawn — GNU runs an exempt coproc or async body in a real fork that inherits the node's flag (execute_cmd.c:2546execute_coproc→execute_in_subshell, fork atexecute_cmd.c:1576). Rubash respawns those bodies in a freshrubash -cprocess whosesuppress_errexitseeded 0. A__RUBASH_SUPPRESS_ERREXITenv stamp now brackets the respawn (env entry →init.rsseeds the child). Procsub children are deliberately NOT stamped —subst.c:6362builds them without the flag path (! cat < <(set -e;false;echo x)prints nothing under GNU 5.3.20).comsub_ignore_returncounter — ported fromexecute_cmd.c:252: raised aroundexpand_wordsof a flagged simple command (execute_cmd.c:4616), a flagged[[ ]]'s operand expansion (execute_cmd.c:4012/:4060/:4067), and rubash's pure-assignment RHS loop (execute_empty_words_command— it bypassesexpand_command_words, so! x=$(...)never saw the bracket). While held,builtins/evalstring.c:496stampsCMD_IGNORE_RETURNon every command a$( )body parses. The comsub boundary now clearssuppress_errexitonly when the counter is zero; thesubst.c:7023-7029errexitenv /errexit_ignore_frameclears are unchanged.Verified byte-identical vs GNU bash 5.3.20 across: invert/if/while/until coproc, async
&,! x=$(…),if z=$(…),! eval 'w=$(…)',! { v=$(…) }, function-body assignment under! f, plus plain coproc / plain comsub / procsub staying dead.exec16.subbyte-identical; 4 new pin tests intests/issue3605_errexit_suppression_transport.rs.Refs #3605