Skip to content

fix(executor): splice mid-word procsub paths in builtin argv (Refs #3353) - #3439

Merged
caomengxuan666 merged 5 commits into
masterfrom
fix/3353-builtin-midword-procsub-splice
Nov 15, 2026
Merged

caomengxuan666 merged 5 commits into
masterfrom
fix/3353-builtin-midword-procsub-splice

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因(待 box 实测确认)

内建命令参数词的中段进程替换在 command_with_process_substitution_files(src/executor/external_setup.rs,materialize_process_substitution_word)里用 word.replacen(&substitution.target, &display_path, 1) 拼接。substitution.target 是 parser 从 raw 词切出的跨度原文(含体内引号,如 >(printf 'hello\n' > ./cap.txt)),而到达拼接点的词已由 expand_command_words 去引号,replacen 命中失败、静默丢失;组体已由 process_substitution_child_fd_word 生成执行,故 cap.txt 仍落 hello、唯独 fd 路径未拼进词。

GNU 锚点

subst.c:11364-11378(expand_word_internal 的 </> 臂):extract_process_subst 的结果经 process_substitute 拼进正在展开的词,与消费命令是内建还是外部无关。

本 PR 删除了什么

无(本 PR 只加回归钉;修法随后提交)。

状态

UNVERIFIED-BY-CAPTAIN — 回归钉先行 fail-first,修法在途。

@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain review: FAIL (2026-11-14) — the current head cannot merge, for two independent reasons, both proven first-hand.

F1 — TEMP-DEBUG commit dc16151 is a live regression on every command's stderr

Commit dc16151f ("TEMP-DEBUG: trace procsub splice inputs for #3353 (revert before final)") adds four unconditional eprintln! traces in external_setup.rs, one of them ([3353-DBG] mat …) firing per word on the generic command-setup path, before the is_empty branch. Attribution is bilateral and mechanical:

  • CI run on the pin-only head 70bfa0b (43230163192): all green.
  • CI run on the current head dc16151 (43233930391): 43 failures across goldens (39), Compatibility CLI (1) and Rust tests (3, including sync_corpus at "14 of 81 corpus cases failed"). The failure log (1,022,024 B) contains 3353-DBG 457 times; ordinary non-procsub commands (sleep, mkdir, cat) show actual stderr beginning with the DBG line. The only delta between the two runs is dc16151.
  • This is not a splice-logic regression and not baseline noise: any exact-stderr consumer on the setup path fails. Dropping dc16151 removes the whole batch.

F2 — The PR contains no product fix for #3353

The only src/ change is the debug tracing; the body itself says the fix is still to come. The pin's defect cells (01/02/03/07) are red by design on this head. Same class as PR #3450's FAIL: a PR whose title promises a fix that is not in its diff cannot merge.

Rework spec

  1. Drop dc16151 entirely; keep the pin file (tests/issue3353_builtin_midword_procsub_splice.rs, 7 cells — its expectations were verified cell-for-cell against the GNU 5.3.20 oracle this round) unchanged.
  2. Re-derive the root cause on current master: the splice loop this PR was written against has been refactored since the branch point (behind 33; materialize_process_substitution_word now at ~:2897 with three replacen sites, after fix(executor): materialize numbered-fd output procsubs in compounds and link fd>=3 chains (Refs #3491) #3504 and 链式输出 procsub > >(A) > >(B) 载荷不穿链(GNU 穿链,物化模型边界) #2234 landed). A fix written against the base shape arrives stale.
  3. Acceptance legs for the new head: pin 7/7; fail-first on current master exactly 4 red / 3 green by name; goldens back to 0 red; sync corpus 81/81; lib bilateral name sets empty (bin-first); -D warnings clean; hygiene scripts pass.

The defect mechanism itself is real and the GNU anchor (subst.c:11364-11378) checks out — this FAIL is about the head's state, not the diagnosis.

caomengxuan666 and others added 3 commits November 14, 2026 23:45
…(Refs #3353)

The recorded substitution target is the raw span spelling; word
expansion rewrites the span interior (quote removal, inner $ / backquote
evaluation) before materialization, so replacen(target) missed on
mid-word embedded spans for every consumer — builtins saw the raw span
text while external commands recovered through a second materialization
pass that rescanned the expanded word. Rescan the expanded word once on
a miss and pair spans by order; the recorded source still feeds the
body, preserving its quoting (GNU subst.c:11364-11378 /
extract_process_subst, subst.c:1311).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3439 第2轮 — 建议:PENDING(缺腿)
head: f5bbec3 base(merge-base): 55fd6a0 文件: 2 个 +289/-4
关联 issue: #3353(状态:open,我核过的时间:2026-11-15)

机制核查:

  • 根因:command_prepare.rs 的全词展开把内嵌 procsub span 内部先改写(脱引号、求值 $/反引号),materialize_process_substitution_word 里 replacen(recorded raw target) 对中段形必 miss;外部命令靠 execute_external 的第二次 materialize(metadata 已清空 → WordMetadata::new 重扫展开词)意外命中,内建只有第一遍 → 拼接丢失。
  • 修复:raw target 未命中时对展开后 word 重扫 span、按序配对(计数一致才采用),body 仍用记录的 raw source 保引号。GNU 锚点:subst.c:11364-11378 expand_word_internal 的 < / > 分支从「正在展开的词」里抽取 span 并拼接 /dev/fd/N,不分消费者;subst.c:1311 extract_process_subst 为扫描规则;subst.c:6362 process_substitute 执行 body。
  • 无关改动:无。f5bbec38 之前已 revert TEMP-DEBUG 提交(2f8b1110)并 merge master(4538cfdb)。

腿:

  • 钉自跑:issue3353_builtin_midword_procsub_splice 7 passed / 0 failed
  • fail-first:base 55fd6a0 + 钉 → 3 passed / 4 failed,红名 = {issue3353_01_echo_midword_output_procsub_splices_dev_fd, 02_printf_…, 03_echo_midword_input_…, 07_echo_midword_output_procsub_double_quoted_body},与缺陷格 {01,02,03,07} 一致
  • lib 双边:head 失败名集 {api::consumer_tests::issue2084_session_end_restores_host_process_state} / base 失败名集 {同} / 差集 ∅(该失败为基线:先在 detached base 1350/1/4 复现,head 同为 1350/1/4)
  • -D warnings:cargo check --lib 0 警告
  • 卫生:rustfmt --check external_setup.rs 干净(全仓 cargo fmt 受 Windows 命令行长度 os error 206 限制,已单文件验证);marker-lint OK(117 consts / 268 sites);utf8-hygiene clean
  • CI(head f5bbec3):3 红 → GNU goldens 与 macOS Rust tests 均仅 issue2875_input_procsub_child_runs_as_rubash_shell(基线,consumer_tests.rs:2911 前置条件签名);Linux Rust tests 首跑红 issue2859_jobs_face_stopped_job_counts,重跑后仅剩 issue2875 → 判定为 flaky,非本 PR 帐。master 同期 CI 红名同为 issue2875。
  • GNU 对照(wsl bash 5.3.20(1)-release,脚本 target/probes/p3439.sh):
    • echo pre>(printf 'hello\n' > ./cap.txt)post → GNU: pre/dev/fd/Npost / 本PR: pre/dev/fd/Npost 一致
    • printf '%s\n' pre>(…)post → 双侧 pre/dev/fd/Npost 一致
    • echo pre<(printf 'hello\n')post → 双侧 pre/dev/fd/Npost 一致(printf: write error: Bad file descriptor 为双侧同款竞态,非回归)
    • echo pre>(printf "hello\n" > ./cap.txt)post → 双侧 pre/dev/fd/Npost 一致;cap.txt 双侧 hello

F 点回应:

  • F1(TEMP-DEBUG 调试提交 dc16151 污染 stderr,43 红):已摘除 — revert commit 2f8b111 移除全部 4 处无条件 eprintln!,未改写已推历史。
  • F2(缺产品修复,只钉不修):已实现 — commit f5bbec3,根因与机制见上;外部第二遍重扫路径证明「展开词上定位 span」是既有语义,本修复把同一定位手段接到第一遍 materialize 的 miss 分支。

续作记录:

  • 2f8b111 Revert TEMP-DEBUG;4538cfdb merge master@55fd6a02;f5bbec38 splice 修复
  • 新 head: f5bbec3(已推送远端,push 前核对远端 head 仍为 dc16151 未被推进)

未跑/VOID 的腿:

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-REWORK】

PR #3439 第3轮 — 建议:PASS(缺腿补齐)
head: f5bbec3(与第2轮审计一致,无人推进) base(merge-base): 55fd6a0
关联 issue: #3353

本轮补腿(WSL Linux /root/rubash-wsl,CARGO_INCREMENTAL=0,cargo test --locked -j 2):

  • cargo test --test issue2036_s5_sync_corpus → 2 passed / 0 failed(corpus_covers_the_conflict_universe + sync_corpus_engine_matches_recorded_expectations——81 格语料为数据驱动断言,全部与记录期望一致)。
  • cargo test --test marker_leak_golden → 21 passed / 0 failed(goldens 全格:每输出通道 marker 泄漏断言全绿)。

未动代码;其余腿按第2轮审计记录全绿(钉自跑 7/0、fail-first 4 红、lib 差集 ∅、CI 红名全 = {issue2875} 基线、GNU 对照一致)。判词翻 PASS,按协议 squash 合并。

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