Skip to content

fix(executor): TMOUT judgment for compound commands fed by raw <(...) redirects (#1141) - #1521

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix4/slice-tmout
Oct 25, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix4/slice-tmout

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #1141

第四波第一片:#1141 TMOUT 剩余三例(select 重定向 c22、组 read c23、组双 read c24)全部修复,同根因的 while/for 重定向形态一并对齐。

根因(一句话)

复合命令不经简单命令的 prepare 侧门,其 fd 0 上的原始 <(…) 重定向到达绑定器时三条计时路径全部落空,最终被无计时的灌入路径物化并清掉计时,于是组内 read/select 永远等生产者出完数据、TMOUT 永不触发。

改动范围

  • src/executor/command_input_scope.rs(+59 行,单文件):bind_command_fd0_input 新增一臂——fd 0 的原始 <(…) 输入重定向直接以计时变体物化并绑到带时刻表的端点,read/select 的 TMOUT 判定由此成立;物化失败落回原路径。未动执行器核心调度,无载体字节改动。
  • tests/issue1141_tmout_compound_redirect_regressions.rs(新增,156 行):[bug] TMOUT ignored by read and select #1141 全矩阵回归固化 11 例(三例本体 + while/for + 无 TMOUT 对照 + 及时数据防误触发守卫 + 已合形态守卫 3 条),与修复同 commit。

验证数字(集成分支实测,门控配方)

  • cargo build --locked:通过。
  • cargo test --locked --lib:728 passed / 1 failed,唯一失败 ownership_unary_operators_check_existing_file(许可的环境项,root 环境)。
  • cargo test --locked --test issue1141_tmout_compound_redirect_regressions:11 passed / 0 failed。
  • 246 条原创差分(对 GNU bash 5.3.20):244 PASS / 2 FAIL = {gl08, ms10},即许可失败集,无新增。
  • 改动文件 fmt-clean,CR 计数 0(LF 保持)。

残差与抖动说明

  • c30 第二读边界(计时容差):组部分行双读的第二读截止恰落在最后一笔数据到达时刻(预算 2.0s + 消费者调度时延)上,判定落在容差带内:GNU 稳定超时,本实现本机负载下偶给读到。回归测试对该例只断言确定性的第一读(142 x=[a]),第二读不断言并在注释中注明;管线形同一脚本两边一致。
  • ps06 抖动:簇内差分曾出现 ps06(wait -n 状态竞态)单次 FAIL,同二进制单例 6 连跑 3 过 3 败,属既有 part_036 作业通知竞态族,与本改动面(fd 0 的 <(…) 绑定)无关;本片集成分支差分一轮 ps06 为 PASS,稳定失败集仍为 {gl08, ms10}。

…directs (rubash#1141)

Brace groups, select and loops dispatch before the simple-command
materialization gate, so a `< <(...)` redirect_in reached
bind_command_fd0_input still in raw substitution form. The binder
only recognized materialized stream paths, so the node fell through
to command_input_redirect -> loop_redirect_input, which slurps the
body untimed into FUNCTION_STDIN and clears timed_stdin: TMOUT could
never fire for the compound\x27s reads or select queries
({ read x; } < <(sleep 2; echo hi) returned rc=0 x=[hi] instead of
rc=142 x=[]; select consumed the late answer with end rc=0).

The binder now materializes the raw form itself via
process_substitution_output_bytes_timed (the same timed variant the
prepare path runs for simple commands) and binds fd 0 to the timed
process-substitution endpoint for the compound scope. The endpoint
is scope-private: no registry entry, no temp file, no offset
write-back on restore. A body that fails to materialize falls
through to the previous paths unchanged.

GNU anchors: builtins/read.def:506-519 (TMOUT arms the read alarm;
timeout returns 128+SIGALRM with the arrived partial input assigned,
read.def:528-554); execute_cmd.c:3426/3578 (select\x27s query is the
read builtin, so a timed-out select read ends the loop with
EXECUTION_FAILURE); subst.c:6362 process_substitute (the body runs
concurrently, so consumers observe real arrival times — the recorded
production schedule is the equivalent evidence).

Regression coverage: tests/issue1141_tmout_compound_redirect_regressions.rs
(11 tests: group read x2, group partial prefix, select redirect,
while/for redirect forms, no-TMOUT and prompt-data guards, plus the
previously fixed direct/pipeline/function forms as anti-regression
guards). Verified against the self-compiled GNU Bash 5.3.20 oracle:
34-case TMOUT probe matrix byte-identical except one documented
arrival==deadline boundary case; cargo test --lib 728 passed / 1
failed (pre-existing ownership environment item only); 246-case
differential 243 pass, stable failures {gl08, ms10} plus the flaky
pre-existing ps06 wait -n race (3/6 pass on identical reruns).
@caomengxuan666
caomengxuan666 merged commit 7bf3c58 into master Oct 25, 2026
5 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix4/slice-tmout branch October 30, 2026 01:41
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.

[bug] TMOUT ignored by read and select

1 participant