Skip to content

tests: true-baseline runs two different test-helper implementations (Rust recho/zecho vs support/recho.c) and diffs their output — 9 of the 21 residual suites depend on them #767

Closed

Description

@caomengxuan666

What I ran

scripts/true-baseline.sh unmodified, oracle = WSL GNU bash 5.3.0 (/usr/local/bin/bash), arm = current master, both profiles, all 83 suites, RUB_OVERRIDE only:

arm stdout byte-identical suites with a diff total diff lines
target/release/rubash.exe 62/83 21 392
target/debug/rubash.exe 61/83 22 383

(The profile difference is 9 lines total — array 18→12, coproc 6→4, test 10→8, intl 0→1 — so it is not material; I am not claiming anything about it here.)

The finding: the two sides do not run the same helper

scripts/true-baseline.sh puts $BASE first on PATH for both sides and stages two different implementations of the same helper in it:

target/issue-suites/results/bash-tests-rw/recho      -> ELF executable      (support/recho.c, gcc in WSL; oracle side)
target/issue-suites/results/bash-tests-rw/recho.exe  -> MS-DOS executable   (scripts/test-helpers/recho.rs; arm side)

Same shell, same argv, one command apart:

wsl bash -c 'cd /mnt/d/repo/rubash/target/issue-suites/results/bash-tests-rw && ./recho "$(printf "a\x80b")" | od -An -tx1'
   61 72 67 76 5b 31 5d 20 3d 20 3c 61 80 62 3e 0a      # raw 0x80 passed through
wsl bash -c 'cd /mnt/d/repo/rubash/target/issue-suites/results/bash-tests-rw && ./recho.exe "$(printf "a\x80b")" | od -An -tx1'
   3c 61 ef bf bd 62 3e 0a                              # 0x80 replaced by U+FFFD

zecho / zecho.exe behave identically (61 80 62 0a vs 61 ef bf bd 62 0a), and the Rust helper also decodes some bytes instead of rejecting them — in the recorded nquote4 artifacts the oracle prints <ab\ufffd> where the arm prints <abÞ> / <abÍe>, i.e. Latin-1/CP1252 interpretation rather than raw-or-U+FFFD.

Why this lands in the "attributable" column

29 of the 83 .tests reference recho/zecho/printenv; 9 of the 21–22 suites that differ depend on them:

array  assoc  comsub-posix  glob  nameref  new-exp  nquote  nquote4  read

For array (lines 295/298/301) and nquote4 (lines 6-8) the entire diff is helper-rendered argv[i] text. Under AGENTS.md §"Required handling when a diff is traced to a WinuxCmd binary" the ledger must be split rubash-caused vs environment-caused with a covering issue number — but a difference between two test-helper implementations is neither, and it is currently counted on the rubash side. The script's own env= classifier does not catch it either (it only fires on NTFS-illegal filename tokens).

Suggested fix (either one is enough)

  1. Make scripts/test-helpers/recho.rs / zecho.rs byte-exact against third_party/bash/support/recho.c for non-UTF-8 input — pass raw bytes through, or emit exactly the same escape form; or
  2. run the same implementation on both sides for the ledger (the gcc-built helper is already produced for the oracle side).

Plus, cheaply: a helper-parity preflight at the top of the harness that runs both helpers over a fixed argv set including invalid UTF-8 / non-ASCII bytes and refuses to start the ledger if they disagree. That way a harness-side difference can never be charged to the engine again.

Notes

  • Script unmodified; the only environment I set was RUB_OVERRIDE / LOG_OVERRIDE. No WARN was emitted, and the /bin/sh fixture (target/sh-fixture/sh.exe) was present.
  • My two ledger logs are target/issue-suites/results/verify-master-true-ledger.log and …/verify-debug-true-ledger.log, per-suite artifacts under …/true-baseline/<suite>/ (I snapshotted the previous contents to …/true-baseline.snapshot-20261017 first so nothing of yours was lost). Say the word and I will delete all of it.
  • I am not asking for anything about the 21–22 raw diffs themselves — the env classes are documented in AGENTS.md with worked examples (posixexp 169→23, globstar→WinuxCmd ls) and I am not disputing them. This is only about the helper pair.

Activity

  1. added
    bug
    platform:windows
    P2-medium
    tests
    on Oct 17, 2026
  2. added 2 commits that reference this issue on Oct 18, 2026
  3. arookieofc commented on Oct 19, 2026

    @arookieofc
    Member

    Verified the a5980de fix end to end on this machine, no new PR needed since it is already on master.

    What I ran (fresh builds from source, real producer paths on both sides):

    • oracle carrier: gcc -O1 from third_party/bash/support/recho.c and zecho.c, argv produced by GNU printf under /usr/local/bin/bash, script-file driven;
    • arm carrier: rustc -O from scripts/test-helpers/recho.rs and zecho.rs, argv produced by rubash printf with the PE spawned by rubash from a script file (the exact harness producer path).
    • 13-format matrix mirroring the helper_parity gate (ASCII, controls, DEL, isolated 0x80-0xff escapes, lone 0xc3 / 0xe4 0xb8, empty argv, multi-arg), outputs compared byte-for-byte.

    Result: 11 of 13 formats byte-identical across both helpers, including x\x80y and \xfe\xff - the U+FFFD-vs-raw divergence from the issue is gone. The only 2 remaining diffs are the harness.s own documented report-only tier (caf\xc3\xa9 through recho and zecho: GNU keeps raw bytes C3 A9, rubash printf decodes to U+00E9 so the wire carries one 0xE9 byte) - engine byte-reencoding family, never charged to the helpers, exactly as the preflight classifies them.

    One aside: this machine.s /usr/local/bin/bash reports version 5.3.15, so the true-baseline.sh contractual-version gate (case version 5.3.0) exits 9 here and the harness itself could not be run as-is; the probe above replicates its helper_parity matrix directly. If the 5.3.15 string is the new owner-compiled baseline, the gate may want to accept the patchlevel form.

  4. caomengxuan666 commented on Oct 20, 2026

    @caomengxuan666
    MemberAuthor

    Re-verified with a fresh build of the current helper — the U+FFFD substitution is still there

    Thanks for the helper_parity gate; the preflight idea is exactly right. But I cannot reproduce "the U+FFFD-vs-raw divergence is gone", and I would rather show you the command than argue.

    I compiled the helper from the current source (scripts/test-helpers/recho.rs, rustc -O, 136,192 bytes — not the stale .exe staged in target/), then fed both helpers the same argv from the same shell (WSL bash, which is also what produces the oracle's argv):

    cd <dir with the C recho and the fresh Rust one>
    wsl bash -c './recho      "$(printf "a\x80b")" | od -An -tx1'
    wsl bash -c './recho_new.exe "$(printf "a\x80b")" | od -An -tx1'
    argv GNU C recho fresh Rust recho
    a\x80b 3c 61 **80** 62 3e 3c 61 **ef bf bd** 62 3e
    a\xffb 3c 61 **ff** 62 3e 3c 61 **ef bf bd** 62 3e
    x\xe9y 3c 78 **e9** 79 3e 3c 78 **ef bf bd** 79 3e
    plain identical identical

    So the pair still disagrees on exactly the inputs in the issue: the Rust helper substitutes U+FFFD for any invalid UTF-8 byte, the C helper passes the byte through. The staged target/issue-suites/results/bash-tests-rw/recho.exe shows the same behaviour, so a ledger driven from the staged tree would see it too.

    A hypothesis for why your 13-format matrix passed, which is worth checking before re-running it: if the arm-side argv is produced by rubash's printf, the byte may already be re-encoded before the helper ever sees it, so the helper is compared on valid UTF-8 and agrees. In my run the argv is produced by a third shell (WSL bash), which is the only way to give both helpers the same bytes. If that is the difference, the matrix is measuring the producer, not the helper.

    Would you paste the 13 inputs (and the producer) from your run? If the matrix really did pass x\x80y through both helpers, one of us is measuring a different object and I would rather find out which than leave a wrong "verified" on the record.

    Not closing this one. Everything else about the gate looks right to me and I would keep it either way — the preflight is more valuable than my original report.

    Related, since it is the same family: the signed-out difference above is also why nquote4/array showed helper-rendered argv[…] diffs in the baseline. If the helper is fixed later, those two suites should be re-checked with the preflight in place.

  5. caomengxuan666 commented on Oct 20, 2026

    @caomengxuan666
    MemberAuthor

    Correction to my own hypothesis — and a likely explanation for the "11/13 green"

    Two things I got wrong in my previous comment, both now measured.

    1. "The arm-side producer re-encodes the byte, so the helper never sees it" — false

    I replicated the gate's own producer path exactly: oracle = GNU printf + ELF helper; arm = rubash printf + the PE helper, both driven through the same .parity.sh shape the gate uses. Both arms are asserted non-empty (see §2 for why that matters):

    format oracle (GNU printf → ELF) arm (rubash printf → PE)
    plain <plain> <plain> EQUAL
    x\x80y … 3c 78 **80** 79 3e … 3c 78 **c2 80** 79 3e DIFFERS
    a\x80b … 3c 61 **80** 62 3e … 3c 61 **c2 80** 62 3e DIFFERS
    \xfe\xff … 3c **fe ff** 3e … 3c **c3 be c3 bf** 3e DIFFERS

    So the pair still disagrees under the gate's own producer — x\x80y among them, which is one of the formats your note says is byte-identical. Note also that rubash's printf itself emits the raw byte (78 80 79, verified), so the c2 80 appears between printf's output and the helper's argv — i.e. on the spawn/argv path, not in the helper's input. (Inference, not read out of the code: that half looks like the engine's byte-reencoding family rather than the helper's U+FFFD.)

    2. My first replication of your matrix produced an all-green table that meant nothing

    The first version of this exact script printed same? YES for every format. Both streams were empty: the WSL side had no cd into $BASE, so recho was not found; the arm side produced nothing either; and b"" == b"" is a pass. That is precisely how a parity gate can report "11/13 ok" while comparing nothing.

    Two lines fix it, and I would add them to the gate regardless of what happens to this issue:

    [ -n "$g" ] || { echo "FATAL: oracle helper produced no output for '$fmt'"; exit 9; }
    [ -n "$r" ] || { echo "FATAL: arm helper produced no output for '$fmt'"; exit 9; }

    (Also worth asserting that the argv actually round-trips: recho echoes it, so a non-empty output that does not contain the expected number of argv[…] lines is still a failed comparison. My empty-vs-empty case had zero lines on both sides.)

    Where that leaves the gate

    With non-emptiness asserted, three of the four formats above are red today, and they need two different fixes:

    • the helper must pass invalid UTF-8 bytes through instead of substituting U+FFFD (the arm-side output under a third-shell producer is still ef bf bd — that measurement is unchanged from my previous comment);
    • the argv path must stop turning 0x80 into c2 80 (and fe ff into c3 be c3 bf) before the child sees it, which is the engine-side half and is what your report-only tier already names for café/中文.

    So: the preflight design is right, its scope is right, and it is not green — it is currently passing because the comparison cannot tell "equal" from "both empty". That is the only thing I would change before trusting it.

    Refs #767, #746.

  6. caomengxuan666 commented on Oct 22, 2026

    @caomengxuan666
    MemberAuthor

    Closing the loop on the gate-green dispute with fresh measurements.

    State on master (verified on this machine, both carriers rebuilt from source, arm = fresh master build): the helper unification from a5980def holds — the gate is green for real, not vacuously. Replicated helper_parity exactly: oracle = GNU printf under /usr/local/bin/bash 5.3.20 → gcc ELF; arm = rubash printf → rustc PE spawned by rubash.

    format result
    plain, two args, \n, a\001b\177c, \x01\x02\x1f, \x7f, mix \x01\x02 end byte-identical
    x\x80y, \xfe\xff, \xc3, \xe4\xb8 byte-identical — the c2 80/ef bf bd divergences do not reproduce; 0x80 arrives as U+0080 on the wire and decodes back to the raw byte
    caf\xc3\xa9 differs (oracle c3 a9, arm e9) — the gate's own documented report-only tier (engine byte-reencoding family, #540 class), exactly as designed
    \xe4\xb8\xad byte-identical (codepoint > 0xFF re-encodes to the same UTF-8)

    What was still true: the empty-vs-empty hole. Reproduced it against the real pre-change script by putting a no-output od first on PATH (delegating -N calls so is_elf still works): helper-parity: gate green (26 ok, 0 report-only) while comparing literally nothing — both dumps empty, "" == "", pass.

    Fix: PR #1182 adds the two assertions requested in this thread — every .parity.sh invocation ends with a literal tail-arg operand, so the gate now requires its bytes (7461696c2d617267) in both whitespace-stripped dumps before any equality test. Same stubbed-od run now prints 26 FAILs → FATAL exit 9. One check covers empty capture, command not found, and spawn failures.

  7. added a commit that references this issue on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumbugplatform:windowstests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions