Repository navigation
fix(executor): resolve sequential 2>&1 against the dup-time snapshot (Refs #3403) - #3631
Conversation
…(Refs #3403) The sequential pipeline driver folded a stage's stderr into the pipeline output stream whenever the fd table held fd 2 on the Stdout endpoint, without checking whether the pipeline's own fd 1 was still that same object. A later `1>file` in the same redirect list — or an `exec > file` inside the body — had already retargeted fd 1, so `{ echo hi | ls /bad; } 2>&1 1>out.txt` sent the stage error into out.txt instead of stdout. GNU applies a redirect list left to right (redir.c:237 do_redirections) and `2>&1 means dup2 (1, 2)` (redir.c:1192-1193): fd 2 is dup'd from fd 1 as it stands at the moment of the dup, and the undo snapshot (redir.c:1170) preserves that binding. The new `ambient_stderr_merges_into_pipeline_output` gate folds only while fd 1 is still the object fd 2 was dup'd from (same Stdout endpoint and same capture generation, as recorded by fd_table dup_entry at dup time and cleared by open_output on retarget); otherwise the bytes ride write_default_stderr, which resolves the fd-2 snapshot itself — the same route the concurrent drivers' intermediate-stderr drain already uses. Wired at both sequential fold sites (external-prefix path and stage loop); concurrent drivers, the streaming-sandwich admission gate and pipeline_stage_stderr_may_stream are untouched. Regression pin: tests/issue3403_sequential_dup_snapshot.rs (7 cells: snapshot/mirror/non-final/no-retarget/exec-retarget ls cells on unix plus builtin cd twins, platform-independent). Refs #3403
7e8f7ac to
3d4adf7
Compare
|
【WIN-AGENT-AUDIT】PR #3631 第1轮 — 建议:FAIL 机制核查:
腿(逐项给数字与名字):
F 点(建议 FAIL):
未跑/VOID 的腿:
|
…xternal stages (Refs #3403) The two platform-independent cells interpolated the temp path unquoted, so the parser read `\U...` as an escape and `:` as a marker: the redirect target became a PUA-named file in the repo root and the mirror cell failed for a test bug, not a product bug. Every interpolated path now goes through `sq()` (single-quoted, `parse.y:5305 read_token_word` keeps the run literal). Discrimination (audit F2): a builtin stage's diagnostic never rides the captured-stderr accumulator, so both `_builtin` cells are controls that are green before and after the fix. The fix lives on the captured-stderr stage paths, so the new `_external` cells re-enter the shell under test as an external stage (`rubash -c 'cd /bad'`) and run on every platform: snapshot (`2>&1 1>f`) and body `exec > f` are base-red/head-green, mirror order and the no-retarget rubash#1552 shape are controls. GNU oracle (5.3.20, script files): redir.c:237 do_redirections applies the list left to right and redir.c:1192-1193 makes `2>&1` a dup2(1,2) of the descriptor as it stands at dup time, so the stage diagnostic stays on the original stdout in the snapshot and exec-retarget shapes, and lands in the file in mirror order.
|
【LANE-o4 返工】PR #3631 第2轮 — 建议:PASS head: F 点逐条回应
腿(数字与红名)
GNU 对照(WSL GNU bash 5.3.20(1),脚本文件;未用
|
|
【WIN-AGENT-AUDIT】PR #3631 第2轮(lane o3 收网)— 判词:PASS(可合) head: F 点逐条回应
GNU 对照(WSL GNU bash 5.3.20,脚本文件)
其他腿
结论产品修法 byte-match GNU,钉 head 绿 / base 红且红名一致,lib 差集 ∅,warnings 0,Linux 原生 11/11。合入。 |
判词 P — 收网合并(head
|
…Refs #3839) chore(ci): allowlist the five reviewed strmatch.rs byte->char sites Refs #3839 Scripts-only change: five tight allowlist entries in scripts/check-utf8-boundary-hygiene.sh, one per `as char` site in src/executor/strmatch.rs (:135, :136, :158, :284, :285), each reviewed safe against the GNU source (bash lib/glob/smatch.c:301-304 FOLD over unsigned char; smatch.c:585-603 xstrmatch routing). No product code touched, no gate logic weakened — the gate still fails any new unreviewed `as char` site. Per-site: :135/:136 lift pattern/string bytes through the Latin-1 bijection GNU's single-byte compile uses (equality/ordering preserved); :158 folds only after is_ascii_uppercase (result 0x61..=0x7A by construction); :284/:285 are POSIX_COLLSYMS table bytes (all ASCII, equality-only / <= 0x7F). CI at head 88d0182: Rust tests PASS (hygiene step 4 cleared); goldens 3 cells (2 baseline + golden_issue1230, the known #3631-window cell); census 79 cells, all known flake families (script-only PR, product-face flips are flakes by construction); all other jobs pass, canary green. Closes nothing by itself — #3839 is hand-closed after this merge.
…g (Refs #3845) (#3847) find_user_command's hash-mirror consult handed phash_search's stored string to callers verbatim as a PathBuf. The hash table keeps the shell-domain display spelling (/d/..., ./elem/name) for `hash -t` fidelity; on unix that string already is the filesystem path execute_cmd.c:6133 shell_execve execve()s, but on Windows it is not spawnable — Command::new ENOENTs and the diagnostic escapes to the shell's stderr, e.g. `cat cap4 | wc -c` inside a command substitution after any earlier `cat` run recorded the entry (golden issue1230). Introduce: #3554 (46bb796) replaced `return Some(path.clone())` — the mirror's fs path — with the verbatim served spelling for the CHKDOT/RELPATH re-validation arm. #3631 is innocent: the parent tree (9148457) reproduces the leak identically. Return shell_path_to_windows(served) instead — the same funnel record_command_resolution used to build the mirror. It is the identity on unix, maps /d/... to D:\..., and keeps ./elem/name relative so the post-cd ENOENT re-resolution of rubash#2696 is preserved. The checkhash probe now stats the real file too. Pin: executor::path::tests:: hash_consult_returns_spawnable_fs_path_for_display_spelling (red before, green after). Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
根因
顺序管道驱动在 fd 表把 fd 2 记在 Stdout 端点时,就把 stage 的 stderr 折进管道输出流,完全不核对管道自身的 fd 1 是否还是同一个对象。同一重定向表里后出的
1>file(或体内的exec > file)已经把 fd 1 重定向走,于是{ echo hi | ls /bad; } 2>&1 1>out.txt把 stage 报错送进了 out.txt,而不是 stdout。GNU 锚点
do_redirections:重定向表从左到右逐项执行。2>&1 means dup2 (1, 2)——fd 2 从 dup 那一刻的 fd 1 复制,undo 快照见 redir.c:1170 附近。{ echo hi | ls /bad; } 2>&1 1>out.txt时 ls 报错走 stdout,out.txt 为空;镜像顺序1>out.txt 2>&1时报错进 out.txt。修法
新增
ambient_stderr_merges_into_pipeline_output门:仅当 fd 1 仍是 fd 2 被 dup 时的那个对象(同为 Stdout 端点且 capture generation 相同——dup_entry 在 dup 时记录、open_output 在重定向时清除)才折叠;否则字节走write_default_stderr,由它按 fd-2 快照自行解析——并发驱动的 intermediate-stderr drain 早就是这条路。接线在顺序驱动的两处折叠点(external-prefix 路径与 stage loop);并发驱动、streaming-sandwich 准入、pipeline_stage_stderr_may_stream未动。回归钉:
tests/issue3403_sequential_dup_snapshot.rs(7 格:unix ls 的 snapshot / mirror / non-final / no-retarget / exec-retarget,及平台无关的 builtin cd 双胞胎)。本 PR 删除了什么
无删除。仅收紧顺序驱动两处折叠谓词(由裸
write_endpoint(2) == Stdout改为快照门);无公开面变动,无行为删除。验证状态
UNVERIFIED-BY-CAPTAIN —— 队长复核未做。车道腿待补:钉 fail-first + 头绿、邻居 stem、全量 lib 双边、
RUSTFLAGS="-D warnings"check、GNU oracle 对照。Refs #3403