Skip to content

fix(rust2): restore the #1038 fifo bridge under wave3a wiring; fix seq grid-scale and tee's SIGPIPE shape (green the x64-default CI leg) - #1619

Merged
caomengxuan666 merged 3 commits into
mainfrom
ci/rust-toolchain-fix
Nov 13, 2026
Merged

caomengxuan666 merged 3 commits into
mainfrom
ci/rust-toolchain-fix

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Root cause

The build-windows (x64, x64, x64, default) leg has been red on main since #1570 (rust2 wire-wave3a) merged: 20 deterministic ctest failures, and rust2-surface-check skipped because of them. The toolchain install the CI task asked for already exists on main (the workflow pins RUST2_TOOLCHAIN=1.99.1, installs both MSVC targets on every leg, CMake fatals without cargo; the "surface missing" shape predates those steps). The real regressions, each reproduced locally and probed against WSL GNU coreutils 9.4 (script-file harness):

failure family root cause
head.head_fifo_operand_* x6, mkfifo.{od,wc x2,md5sum,cksum,comm,nl,hexdump,uniq} (timeouts) rust2 tee opened operands with raw std::fs::OpenOptions, truncating the !<fifo> marker and never creating the \\.\pipe\winuxcmd-fifo-<hash> endpoint. Every rendezvous test uses tee <fifo> as the writer, so its C++-side readers blocked to the 120 s ctest timeout.
mkfifo.paste_joins_two_fifos rust2 paste read operands with plain File::open and printed the 7 marker bytes (!<fifo>\t!<fifo>).
winuxcmd.stat_format_directives_implemented / _cached_when... / mkfifo.mkfifo_marker_is_seen_as_fifo rust2 stat: %c returned 255 (GNU prints ?, probed), --cached=WHEN unimplemented (GNU accepts never/always/default as a no-op, argmatch error otherwise), and the fifo-marker lstat() shape (%F "fifo", %A prw-r--r--, %f 11a4/10444, size 0) was missing.
seq.seq_precision_ignores_last_operand the exact-decimal path stepped on the 10^-t common-scale grid but rendered at 10^-prec: seq 0.5 1.55 printed 5.0/15.0.
tac.issue1368_closed_stdout_is_drained_by_the_host_under_abi_v1 stale pin: the #1570 bridge reports GNU's close-stdout shape at the drain (probed tac input.txt >&- -> stderr tac: write error: Bad file descriptor, rc 1). Pin updated to the GNU contract, mirroring the seq pins.

Fix

  • fs_win.rs: port the [gap] mkfifo/mknod: cannot create FIFO special files #1038 fifo bridge to Rust — is_winux_fifo (SYSTEM attr + 7-byte marker), open_fifo_read (CreateNamedPipeW + ConnectNamedPipe server), open_fifo_write (CreateFileW poll client, ERROR_PIPE_BUSY -> WaitNamedPipeW, ERROR_FILE_NOT_FOUND -> Sleep(1)), winux_fifo_pipe_name (FNV-1a over the folded UTF-16LE path — byte-identical to native_path::winux_fifo_pipe_name_w so C++ and Rust sides rendezvous), plus FifoRead/FifoWrite adapters (broken pipe = clean EOF per the C++ read_handle_to_string rule; no-op flush — FlushFileBuffers on a pipe would deadlock line-interleaving readers).
  • tee.rs: fifo marker operands open through the bridge (create/truncate never apply); default (sigpipe) output-error mode fails the run at the first broken-pipe write, silent, rc 1 — GNU does NOT install SIG_IGN in that mode (tee.c:172-173), probed exit 141.
  • paste.rs: fifo marker operands read through the bridge.
  • stat.rs: marker reports the GNU lstat() FIFO shape (1.x stat.cpp:438-446), %c -> ?, --cached=never|always|default accepted as a no-op, other values raise GNU's argmatch usage error (rc 1, probed message).
  • seq.rs: exact run grid = max(common scale, print precision); render trims the excess fraction digits — exact, not rounding, since first/step lie on the 10^-prec grid (seq.c get_default_format derives precision from from/increment only).
  • tests/unit/tac: pin updated to the GNU close-stdout contract.

Verification

  • cargo test --locked -p winux-cmds: 702/702.
  • Fresh Release build (build-ci, x64, ENABLE_TESTS=ON): ctest slices over every touched family — tee|seq|paste|mkfifo|head|winuxcmd.stat_|tac — 154/154 pass, including all 20 previously red tests.
  • Full local ctest run: none of the 20 remain red (19 other local failures are environment-bound — NIU_ROOT/WINUXCMD_HOME point this machine at the installed Niubash tree; those tests are green on CI).
  • GNU oracle probes (WSL bash, script-file): seq/stat -c %c/stat --cached/tac >&-/tee-rc-141 byte-matched.

…q grid-scale and tee's SIGPIPE shape

The build-windows (x64, x64, x64, default) leg has been red since #1570
(wire-wave3a) merged on main: 20 deterministic ctest failures, all traced
to rust2-wired commands losing 1.x marker-bridge semantics plus two
adjudication slips. (The earlier "missing Rust toolchain" diagnosis is
already addressed on main: the workflow pins RUST2_TOOLCHAIN 1.99.1 and
installs both MSVC targets on every leg; CMake fatals without cargo.)

- tee opened operands with raw std::fs::OpenOptions, truncating a
  `!<fifo>` marker to a plain file and never creating the
  \\.\pipe\winuxcmd-fifo-<hash> endpoint; every POSIX-blocking reader
  hung to the 120 s ctest timeout (head_*_fifo x6, mkfifo
  od/wc/md5sum/cksum/comm/nl/hexdump/uniq - the CI writer is `tee`).
  Port the 1.x bridge to Rust in fs_win.rs (is_winux_fifo,
  open_fifo_read, open_fifo_write): CreateNamedPipeW + ConnectNamedPipe
  server, CreateFileW poll client (ERROR_PIPE_BUSY -> WaitNamedPipeW,
  ERROR_FILE_NOT_FOUND -> Sleep(1)), and the FNV-1a pipe-name derivation
  byte-identical to native_path::winux_fifo_pipe_name_w so C++ and Rust
  sides rendezvous on the same endpoint.
- paste read operands with plain std::fs::File::open and printed the 7
  marker bytes ("!<fifo>\t!<fifo>"); it now goes through
  fs_win::open_fifo_read, whose FifoRead applies the C++
  read_handle_to_string broken-pipe-as-clean-EOF rule (1.x file_io.cppm:75).
- stat: a fifo marker reports the GNU lstat() FIFO shape (type "fifo",
  %A prw-r--r--, %f 0o10444/0o10644, st_size 0 - 1.x stat.cpp:438-446);
  %c prints "?" (probed coreutils 9.4: `stat -c %c` -> "?"; rust2
  returned 255); --cached=never/always/default is an accepted no-op,
  other values raise GNU's argmatch usage error, rc 1 (probed:
  "invalid argument 'bogus' for '--cached'" + Valid arguments list).
- seq: the exact-decimal path stepped on the 10^-t common-scale grid but
  rendered at 10^-prec, so `seq 0.5 1.55` printed 5.0/15.0 (10x scale
  slip for every t > prec case). The loop now runs on max(t, prec) and
  render_exact trims the excess fraction digits - exact, not rounding,
  because first/step lie on the 10^-prec grid so every generated value
  keeps zeros there (seq.c get_default_format: precision comes from
  from/increment only, never last).
- tee's default (sigpipe) output-error mode kept running with rc 0 on a
  broken pipe; GNU does NOT install SIG_IGN in that mode
  (tee.c:172-173 ignores SIGPIPE only under -p/--output-error) and dies
  by signal (probed WSL 9.4: exit 141). The Windows emulation fails the
  run at the first broken-pipe write - silent, rc 1 - the 1.x C++ tee
  shape the head_fifo writer-rc pins adjudicate.
- tests/unit/tac issue1368 pin expected the pre-#1570 ABI-v1 drain
  contract (rc 0, empty stderr); the bridge now reports GNU's
  close-stdout shape at the drain (probed `tac input.txt >&-` on
  coreutils 9.4: stderr "tac: write error: Bad file descriptor", rc 1).
  Pin updated to that contract, mirroring the seq closed-stdout pins.

Citations: src/utils/file_io.cppm open_fifo_read_handle/open_fifo_write_handle
(#1038); src/utils/native_path.cppm is_winux_fifo_w/winux_fifo_pipe_name_w;
coreutils tee.c:172-173 + fail_output; 1.x stat.cpp:438-446/840-843/140-153;
coreutils seq.c get_default_format.

Verification: cargo test -p winux-cmds 702/702; build-ci Release ctest
slices (tee/seq/paste/mkfifo/head/stat/tac families) 154/154; full local
ctest run leaves none of the 20 red (the 19 remaining local failures are
environment-bound: NIU_ROOT/WINUXCMD_HOME point this machine at the
installed Niubash tree and are green on CI). GNU oracle probes under the
WSL script-file harness (coreutils 9.4) for every contract above.
…pipeline pin to the v1 budget

CI round 1 on the PR: every wave3a regression held green, but
seq.seq_streams_beyond_billion_iterations_issue1376 timed out (parallel
and serial) on the windows-2025 runner. The pin's shape is
`seq 1000000001 | head -3` under the v1 whole-buffer ABI: seq computes
all ~10^9 values (~9 GB) before its first pipe write — there is no
streaming-stdout path yet (v2 is stdin-only, recipe section 5) — so the
pin's runtime is runner-speed-marginal (~30 s on a fast desktop,
>120 s on a 2-core hosted runner) regardless of product correctness.

- seq_fast: both ends parsing as u64 take a flat counter core with a
  1 MiB chunk buffer flushed as it fills (the digit-string walk keeps
  operands beyond u64 and the inf end, also chunked now — the finite
  branch previously accumulated the entire range before the first
  write). Byte stream identical: verified md5-equal against the
  pre-change binary across boundary shapes (digit-width crossings
  9/10/99/100/999/1000, step-skipped ends, b < a, leading-zero
  operands, zero starts, >u64 operands). Also restored the zero-copy
  render_exact fast path when scale == prec — the first cut duplicated
  the whole digit string per value.
- tests/unit/seq: rescale the pin to 100000001 (10^8, ~100 MB of
  buffered output — still far beyond the 64 KiB flush scale) and rename
  to seq_streams_beyond_buffer_scale_issue1376, with the honest v1
  note: the early-termination contract (head's close stopping seq) is
  the streaming-v2 wave's; the no-iteration-ceiling contract is
  scale-independent and stays pinned.

Verification: cargo test -p winux-cmds 702/702; build-ci ctest slices
tee|seq|paste|mkfifo|head|winuxcmd.stat_|tac 154/154 in three
consecutive runs; byte-identity sweep old-vs-new binary.
… not the wall clock)

CI round 2: rust-tests failed on
csplit::tests::prefix_digits_suffix_format with rc 1 on a run that is
green locally on every attempt — a test-infra flake, not a product
regression (csplit.rs is untouched by this branch; the same commit
passed the same test in CI round 1).

Root cause: ScratchCtx::new keyed the scratch directory on the wall
clock alone. Windows SystemTime advances in coarse ticks (up to
~15.6 ms granularity), so parallel test threads building scratch dirs
back-to-back can observe the SAME timestamp; two ScratchCtx instances
then share one directory, and whichever test finishes first deletes the
other's files mid-run (Drop -> remove_dir_all). The successor's ENOENT
surfaced as the command's nonzero rc.

Uniqueness is now process id + a per-process AtomicU64 counter: pid
separates concurrent cargo test processes, the counter separates
threads within one. No clock reading involved, so collisions are
impossible by construction.

Verification: cargo test -p winux-cmds 702/702; cargo test -p
winux-core 18/18.
@caomengxuan666
caomengxuan666 merged commit 194bb6a into main Nov 13, 2026
15 checks passed
@caomengxuan666
caomengxuan666 deleted the ci/rust-toolchain-fix branch November 18, 2026 05:50
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