Repository navigation
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
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The
build-windows (x64, x64, x64, default)leg has been red on main since #1570 (rust2 wire-wave3a) merged: 20 deterministicctestfailures, andrust2-surface-checkskipped because of them. The toolchain install the CI task asked for already exists on main (the workflow pinsRUST2_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):head.head_fifo_operand_*x6,mkfifo.{od,wc x2,md5sum,cksum,comm,nl,hexdump,uniq}(timeouts)teeopened operands with rawstd::fs::OpenOptions, truncating the!<fifo>marker and never creating the\\.\pipe\winuxcmd-fifo-<hash>endpoint. Every rendezvous test usestee <fifo>as the writer, so its C++-side readers blocked to the 120 s ctest timeout.mkfifo.paste_joins_two_fifospasteread operands with plainFile::openand printed the 7 marker bytes (!<fifo>\t!<fifo>).winuxcmd.stat_format_directives_implemented/_cached_when.../mkfifo.mkfifo_marker_is_seen_as_fifostat:%creturned255(GNU prints?, probed),--cached=WHENunimplemented (GNU accepts never/always/default as a no-op, argmatch error otherwise), and the fifo-markerlstat()shape (%F"fifo",%A prw-r--r--,%f 11a4/10444, size 0) was missing.seq.seq_precision_ignores_last_operandseq 0.5 1.55printed5.0/15.0.tac.issue1368_closed_stdout_is_drained_by_the_host_under_abi_v1tac input.txt >&--> stderrtac: write error: Bad file descriptor, rc 1). Pin updated to the GNU contract, mirroring the seq pins.Fix
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 tonative_path::winux_fifo_pipe_name_wso C++ and Rust sides rendezvous), plusFifoRead/FifoWriteadapters (broken pipe = clean EOF per the C++ read_handle_to_string rule; no-op flush — FlushFileBuffers on a pipe would deadlock line-interleaving readers).%c->?,--cached=never|always|defaultaccepted as a no-op, other values raise GNU's argmatch usage error (rc 1, probed message).Verification
cargo test --locked -p winux-cmds: 702/702.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.NIU_ROOT/WINUXCMD_HOMEpoint this machine at the installed Niubash tree; those tests are green on CI).seq/stat -c %c/stat --cached/tac >&-/tee-rc-141 byte-matched.