Skip to content

WIP: procsub operands: byte-correct drain by default, fifo-marker route behind proof key (Refs #2473) - #2485

Merged
caomengxuan666 merged 6 commits into
masterfrom
fix/2473-procsub-multi-operand
Nov 2, 2026
Merged

caomengxuan666 merged 6 commits into
masterfrom
fix/2473-procsub-multi-operand

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

paste <(echo 1) <(echo x) handed the command the literal !<fifo> marker bytes (!<fifo>\t!<fifo>; GNU 1\tx). Root cause is NOT multi-operand assembly — every external WinuxCmd-runtime consumer got marker bytes (paste/wc/od/comm/diff, single operand alike; cat <(echo one) only looked green because rubash's cat is internal). The #2225 delivery gate trusted binary identity ("the WinuxCmd runtime bridges !<fifo> markers on read") as proof — measured against the installed WinuxCmd 1.1.20 that prediction is false on the read side, and its failure is silent operand byte corruption.

GNU basis (vendored third_party/bash)

  • subst.c:11364-11385 — expand_word_internal's </> arm: EVERY <(...) occurrence gets its own process_substitute call (per-operand assembly; N operands → N substitutions).
  • subst.c:6381 pipe() per substitution; subst.c:6392-6394 move_to_high_fd + make_dev_fd_filename (+ add_fifo_list 6343) — each operand a distinct live pipe under its own /dev/fd/N name; subst.c:6412 make_child(FORK_ASYNC|FORK_PROCSUB) forks the body.
  • Contract: whatever consumer opens the substituted name receives the producer's bytes.

Evidence chain

  1. rubash master 1c93ea87 (standalone Windows build): paste <(echo 1) <(echo x) → !<fifo>\t!<fifo>; wc -c <(printf hello) → 7 (the marker's byte count); od -c <(printf hello) → the 7 marker bytes.
  2. WinuxCmd 1.1.20 standalone (no rubash involved): their own mkfifo + od — od reads the marker bytes immediately instead of blocking in the rendezvous, while the writer correctly blocks in the pipe open ⇒ the runtime's applet READ path does not bridge markers. Filed as applet 读路径不桥接 !<fifo> marker(od 读自家 mkfifo 产物得 7 字节字面量,写侧正常阻塞) WinuxCmd#1493.
  3. Timing probe: cat.exe <(echo early; sleep 3; echo late) emitted early only at +3117ms — every previously "green" case was actually the byte-correct drain, never a working bridge.

Change (src/executor/dev_fd_operands.rs)

procsub_operand_delivery inverts admission: identity class is no longer proof. Every consumer takes the byte-correct drain (the pre-#2156 shape) unless the machine-level key RUBASH_PROCSUB_FIFO_MARKER=1 asserts the installed runtime bridges marker reads — the #1959 streaming route stays armed behind that key (a future version probe can replace the manual key once a bridging WinuxCmd release exists). The identity classifier winuxcmd_fifo_marker_aware and its pins are unchanged. This is the #2225 invariant applied to itself: a miss costs streaming, never bytes.

Pins (tests/issue2473_procsub_operand_marker_regressions.rs, #![cfg(windows)])

  • Deterministic, no WinuxCmd install needed: a stand-in aware-class consumer built by hard-linking the rubash binary into a fake WinuxCmd tree (winuxcmd.exe + paste.exe) invoked as paste -c 'cat "$0"' — 1/2/3 operands each carry their own producer bytes; with the proof key a non-bridging reader (cmd /c type) sees the marker path while rubash's own bridging cat still streams through the live rendezvous; the key never reaches non-runtime consumers (findstr); single-operand internal face unchanged.
  • Real-runtime pins (skip when WinuxCmd absent): the issue's paste reproducer, wc -c byte count (5, not 7), comm common-column shape (two tabs), diff <(echo a) <(echo b) actually seeing the difference (pre-fix two identical markers made it report no difference — silent wrong data).
  • Unit pin updated: dispatcher-class consumer drains without the key, marker-routes with it; identity pins in path::tests stand.

Verification

  1. Script-file byte-compare, WSL GNU Bash 5.3.20 vs the fixed Windows binary (same script, same dir): stdout/stderr/rc identical for the reproducer + paste 3-operand + wc count + comm + diff + single-operand cat. Artifacts: target/issue-suites/results/issue2473/.
  2. cargo test --test issue2473_procsub_operand_marker_regressions — 7/7 (stand-in default test red on master: paste <(echo one) → !<fifo>).
  3. cargo test --lib — WSL 1029/0; Windows 1123 passed / 2 failed, both failures byte-identical on pristine origin/master (environment-bound). cargo check --tests (the Windows CI lane command) clean. Neighboring procsub family green except the master-reds already documented in WIP: procsub: inherit ambient exec fds in the <(...) producer fork (Refs #2466) #2472.

Machine info

Windows 10 10.0.19045 x64; standalone master binary D:\capon-build\dlm-target\debug\rubash.exe (1c93ea8) for reproduction; worktree build in an isolated target dir; WSL GNU Bash 5.3.20 (/usr/local/bin/bash).

Notes

Refs #2473
See-also: unixwin/WinuxCmd#1493

…e fifo-marker route (#2473)

GNU assembles multi-operand process substitutions per occurrence:
expand_word_internal calls process_substitute for EVERY `<(...)` word
(subst.c:11364-11385), each with its own pipe (subst.c:6381) under its
own /dev/fd name (move_to_high_fd + make_dev_fd_filename,
subst.c:6392-6394, add_fifo_list 6343) — the contract for every
operand being that whatever consumer opens the name receives the
producer's bytes.

rubash#2225 gated the Windows fifo-marker streaming route on binary
identity ("the consumer IS the WinuxCmd runtime, so its reads bridge
markers"). Measured against the installed WinuxCmd 1.1.20 the
prediction is false on the READ side: paste/wc/od/comm/diff read the
7 `!<fifo>` marker bytes plainly (`paste <(echo 1) <(echo x)` printed
`!<fifo>\t!<fifo>`, `wc -c <(printf hello)` counted 7), and WinuxCmd's
own runtime does not rendezvous with its own mkfifo marker — its `od`
reads the marker bytes immediately while the writer blocks in the
pipe open (unixwin/WinuxCmd#1493). A wrong identity prediction here is
silent operand byte corruption, the exact harm #2225 was written to
prevent, so identity is no longer treated as proof.

The delivery gate now inverts admission: every consumer takes the
byte-correct drain (the pre-#2156 shape) unless the machine-level
RUBASH_PROCSUB_FIFO_MARKER=1 key asserts the installed runtime bridges
marker reads — the #1959 streaming route stays armed behind that key
(pinned end-to-end: with the key a non-bridging reader sees the marker
path while rubash's own bridging cat still streams the bytes through
the rendezvous). The identity classification itself is unchanged
(path::winuxcmd_fifo_marker_aware and its pins stand).

Pins (tests/issue2473_procsub_operand_marker_regressions.rs,
#![cfg(windows)]): deterministic end-to-end tests build an aware-class
stand-in consumer by hard-linking the rubash binary under a fake
WinuxCmd tree (winuxcmd.exe + paste.exe) and invoking it as
`paste -c 'cat "$0"'` — one/two/three operands carry their own bytes,
the proof key flips the delivery, the key never reaches non-runtime
consumers, and the single-operand internal face is unchanged; plus
real-WinuxCmd pins (paste 2/3-operand, wc byte count, comm columns,
diff actually seeing the difference) that skip when the runtime is
absent. Unit pin updated: dispatcher-class consumer drains without the
key, marker-routes with it.

Verification: WSL GNU Bash 5.3.20 vs the fixed Windows binary,
script-file byte-compare — stdout/stderr/rc identical for the issue
reproducer plus paste 3-operand, wc count, comm, diff, single-operand
cat (artifacts under target/issue-suites/results/issue2473/).
cargo test --lib: WSL 1029/0; Windows 1123 passed with 2 failures
both identical on pristine origin/master (environment-bound).
Neighboring procsub family green except the master-reds already
documented in #2472 (issue1959 abandoned-producer et al).

Refs #2473
See-also: unixwin/WinuxCmd#1493
@caomengxuan666
caomengxuan666 force-pushed the fix/2473-procsub-multi-operand branch from e2479a4 to 8403ebd Compare November 2, 2026 00:40
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 2, 2026 00:40
caomengxuan666 and others added 5 commits November 2, 2026 00:51
…t route

issue2225_aware_applet_consumer_gets_marker_operand simulated a
marker-aware consumer by file identity alone. #2473 changed the
contract: file identity is no longer proof (shipped applets read the
marker bytes as plain content), so the streaming route additionally
requires the runtime's RUBASH_PROCSUB_FIFO_MARKER=1 proof key. The pin
now exports the key the way a proven runtime does; the unproven
default stays covered by the drained-operand pins and the
falls_to_drain unit test. Coordinator harvest fix on top of the
author's commit.

Refs #2473
@caomengxuan666

Copy link
Copy Markdown
Member Author

[win-acceptance] #2485 PASS — new pin 7/7 x2 @--test-threads=4; issue #2473 repro shapes byte-identical to WSL GNU Bash 5.3.20: paste <(echo 1) <(echo x) → 1<TAB>x (no !<fifo> placeholder leak), single-operand cat <(echo one) control, 3-operand paste — stdout/stderr 0 diff lines, rc match.

Environment: Windows 10 19045 real machine, MSVC Rust debug build of master 103c6a0 (= this PR's merge step), GNU oracle = wsl bash 5.3.20 script-file comparison. Probe: D:/repo/win-accept/probes/p2473.sh.

Family battery at -j4: issue1021 1/1, issue1220 2/2, issue1223 3/3, issue1336 5/5, issue1460 1/1, issue1959_procsub_argv_streaming 6/6 — all green.

No BLOCKER.

@caomengxuan666
caomengxuan666 deleted the fix/2473-procsub-multi-operand branch November 3, 2026 09:05
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