Repository navigation
fix(testing): make the fuzz CI guards satisfiable and de-flake the JS cancel test - #3023
Conversation
…opped quotes Nightly Fuzz Testing run 45932089002 went red on csv_fuzz and printf_fuzz. Neither was a product bug; both were harness guards reporting inputs they had armed the fuzzer to build. csv_fuzz flagged the host canary in stdout from the input BASHKIT_FUZZ_HOST_CANARY_47a83bcf_D"O_NOT_LEAK. echo passed the bytes through verbatim and csv headers then removed the `"` as its CSV quote character, printing the canary whole, so the output carried a token the script text never spelled and attribution could not account for it. That is the run-272 forgery one parser further down the pipeline: libFuzzer harvests the canary from the detector's own `contains`, and a spliced quote survived the comparison a spliced NUL already did not. carries_through_expansion now strips DROPPED_BY_PARSERS -- NUL from word expansion, and `"`/`'`/`\` from shell quote removal or the csv field parser -- as well as NUL. Stripping can only add matches, and no banned shape and no part of the canary contains any of those characters, so every match it adds is a parser dropping punctuation out of script text, which is an echo by definition. printf_fuzz tripped the stderr byte cap with 1,283 bytes, which was not a flood: printf '%d %o %x' cycles its format over every operand, so 34 non-numeric operands drew 34 `invalid number` diagnostics -- output linear in the input and well inside the max_stderr_bytes(4096) the target itself configures. The harness was holding a whole-execution budget to a single diagnostic's size, so any script landing in 1024..=4096 failed by construction; the cap was unsatisfiable rather than strict. MAX_STDERR_BYTES now matches the largest limit any target configures, which keeps what the assertion was written for: for those targets it says the engine honored the limit it was given, and 10 MB of library spam still fails. A const assertion makes a future mismatch a compile error instead of a nightly-only failure, and the 1 KiB per-diagnostic bound stays where it belongs, in diagnostic_prefix_tests.rs (L-ARITH-002). Both crash units are replayed in fuzz_crash_regressions.rs and reproduce the exact CI failures against the old harness, including the same 1,283 bytes. attribution_does_not_relax_the_stderr_cap had hard-coded a 2,200-byte fixture and would have silently become a no-op, so it is now sized off the constant.
The windows-latest lane of JS run 45816668178 failed on "Ctrl+C aborts a held server connection via ctx.fetch: exit 130" at its `server saw the connection abort` assertion, taking the JS Check gate and main with it. Every other lane passed, and the seven preceding runs on main were green. The product path is not at fault: bash.cancel() aborts the builtin controller synchronously before it calls native.cancel(), and abort() dispatches to undici in the same tick, so the request is already aborted by the time execute() resolves -- which the test confirms independently via exit 130 and its elapsed bound. What remained was the kernel and the server's event loop noticing the socket go away, and the test gave that a fixed 2s of 20ms polling rounds on a single event, `req` 'close'. Neither the delay nor which event lands first is uniform across platforms, so the assertion was timing out on the slowest runner in the matrix rather than catching anything. The test now resolves a promise from `req` 'close'/'aborted' and the socket's 'close'/'error' and races it against one generous timeout. The usual case passes as soon as the event arrives instead of after a fixed wait, a slow delivery no longer reads as a failure, and a genuine failure to propagate still fails because the timeout resolves false. Recorded as a maintenance rule for the ava suite, which runs on windows-latest as well as ubuntu.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 136ced9 | Commit Preview URL Branch Preview URL |
Nov 27 2026, 11:02 AM |
Re-review after push
|
…fuzz one Review of the previous commit caught that raising the single shared MAX_STDERR_BYTES also moved assert_no_leak, the strict per-builtin path the threat model calls absolute, from 1 KiB to 4 KiB -- so a builtin emitting kilobytes of Debug spam would have passed a gate that previously failed it. Only the fuzz path needed the looser figure, because only a fuzz target inlines bytes it did not choose and runs under a limit it declared itself. The two budgets are now separate constants: MAX_STDERR_BYTES stays 1 KiB for assert_no_leak, and the new MAX_FUZZ_STDERR_BYTES is 4 KiB for assert_fuzz_invariants, with the const assertion moved onto it. loosening_the_fuzz_cap_did_not_loosen_the_strict_path pins the split and fails if they are ever collapsed back into one. Two documentation claims were also too strong, and are now qualified where they are made: - The guard does not make the cap satisfiable for every target. Eight of the 26 configure no limit and so take the 1 MiB default, 256x the harness figure, so for them 4 KiB is a deliberate flood bound rather than a satisfiable one and this class of false positive can recur. The fix when it does is an explicit max_stderr_bytes on that target, not a blind raise. - Stripping DROPPED_BY_PARSERS over-approximates: it is unconditional and context-free, while a real parser drops those characters only in particular positions, and attribution is whole-script and whole-stderr. So it can excuse an occurrence no parser would have produced. That is the same residual false negative script_explains already documents, accepted for the same reasons, and erring this direction is right -- under-approximating is what turns the nightly red on the detector's own dictionary. Fixed in passing on the same reporting path: truncate sliced arbitrary fuzz output at a fixed 512 bytes, panicking whenever that offset landed inside a multi-byte character and replacing a canary-leak message with an unrelated backtrace. It now floors the cut to a character boundary.
|
All three findings were real. Fixed in ab7a1db. [P1] [P1] [P2] Pre-existing On the JS note: agreed that a genuine abort-delivery failure now costs 20s Re-validated after the change: Generated by Claude Code |
The csv_fuzz paragraph still read 'an echo by definition', which overstates an unconditional context-free strip and contradicts the qualified wording the same change put on carries_through_expansion. State the over-approximation and the residual it shares with script_explains, as the code comment does.
My previous commit on this test was wrong about the cause and did not fix it: `Runtime callbacks (windows-latest)` failed again on ab7a1db, same assertion, despite a 20s budget and four disconnect listeners. That ruled out slow delivery -- when it fails, the disconnect never arrives at all. The real cause is upstream of the disconnect. The test cancels an in-flight request, but it only assumed the request was in flight, after sleeping 200ms. `bash.execute` has to reach the native interpreter, dispatch the builtin and let undici open the connection within that window, and sibling tests in this file show builtin dispatch taking 1.3-1.5s on windows-latest. When 200ms ran out first, `cancel()` landed before the builtin ran: no request was ever sent, the server handler never ran, so no listener existed to report a disconnect and no later wait could help. The assertion was failing on a request that did not exist. Reproduced on Linux by cancelling before dispatch instead of sleeping, which gives the exact Windows signature -- exit 130, zero requests at the server, zero closes after the original 2s budget. So this needs no platform-specific explanation: Windows just loses the race more often, which is also why the two Windows lanes disagreed run to run while macos and ubuntu stayed green. The cancel now waits on `requestArrived` from the server handler, so it aborts something that exists, and that wait is bounded so a request that never arrives fails where the cause is visible. The elapsed bound is timed from the cancel rather than from `execute`, since it is about how fast cancellation unwinds and would otherwise fold in dispatch and connection setup on a slow runner. The event-based disconnect wait is kept and factored into `raceWithTimeout`.
Correction on the JS failure: my first diagnosis was wrongRecording this because the CI failure above is on this PR and my earlier
The cause is upstream of the disconnect. The test cancels an in-flight request That also explains what the platform theory could not: the two Windows lanes Reproduced on Linux by cancelling before dispatch instead of sleeping: Exit 130, zero requests at the server, zero closes after the original 2s Fixed in 070150d: the cancel waits on Verified: full ava suite 695 passed, oxlint clean. The honest caveat is that Generated by Claude Code |
Review follow-up. A false `arrived` recorded the failure and then fell through into cancelling a request that was never sent, waiting out the full disconnect timeout and reporting a second failure that points away from the cause -- the opposite of what the arrival assertion's message promises. Return there instead; the server still closes via t.teardown and the finally block. The windows-latest lanes both passed on 070150d, including the execution-plan one that failed on ab7a1db, so the dispatch-race diagnosis holds.
What changed
Three CI-side guards stop reporting their own setup as a defect. No product
behavior changes: the only library file touched is
bashkit::testing, the#[doc(hidden)]test-only module, and the rest is tests and knowledge.carries_through_expansionstripsDROPPED_BY_PARSERS— NUL from shell wordexpansion, and
"/'/\from shell quote removal or thecsvfield parser— so a needle spliced with one of those is attributed to the script that
spelled it.
MAX_FUZZ_STDERR_BYTES(4 KiB)matches the largest
ExecutionLimits::max_stderr_bytesany fuzz targetconfigures, while
MAX_STDERR_BYTESstays 1 KiB for the strict per-builtinpath (
assert_no_leak). A const assertion makes a future mismatch a compileerror. The 1 KiB per-diagnostic bound is a third, separate budget and stays
in
diagnostic_prefix_tests.rs(L-ARITH-002).ctx.fetchcancellation test waits for its request to arrive beforecancelling it, instead of sleeping 200ms and assuming so.
Why
Fuzz Testingrun 45932089002 and thewindows-latestlane ofJSrun45816668178 were red on main (and the JS one recurred on this PR at ab7a1db). All three failures were guards misfiring, not
bugs in bashkit.
csv_fuzzreported the host canary in stdout from the inputBASHKIT_FUZZ_HOST_CANARY_47a83bcf_D"O_NOT_LEAK.echopassed the bytesthrough verbatim and
csv headersthen removed the"as its CSV quotecharacter, printing the canary whole — so the output carried a token the script
text never spelled. This is the run-272 forgery one parser further down the
pipeline: libFuzzer harvests the canary from the detector's own
contains, anda spliced quote survived the comparison a spliced NUL already did not.
printf_fuzztripped the stderr byte cap with 1,283 bytes, which was not aflood.
printf '%d %o %x'cycles its format over every operand, so 34non-numeric operands drew 34
invalid numberdiagnostics — output linear inthe input and well inside the
max_stderr_bytes(4096)the target itselfconfigures. The harness was holding a whole-execution budget to a single
diagnostic's size, so any script landing in 1024..=4096 failed by
construction: the cap was unsatisfiable rather than strict.
The JS failure is not a product fault either, but my first explanation of it
was wrong and is worth recording. I read it as slow disconnect delivery on
Windows and replaced the 2s poll with a 20s event-based wait; it failed again
on
ab7a1db, same assertion, which ruled that out — when it fails thedisconnect never arrives at all.
The cause is upstream. The test cancels an in-flight request but only assumed
the request was in flight, after sleeping 200ms.
bash.executehas to reachthe native interpreter, dispatch the builtin and let undici open the connection
inside that window, and sibling tests in the same file show builtin dispatch
taking 1.3–1.5s on
windows-latest. When 200ms ran out first,cancel()landed before the builtin ran: no request was ever sent, the server handler
never ran, so no listener existed to report a disconnect and no later wait
could help. The assertion was failing on a request that did not exist — which
is also why the two Windows lanes disagreed run to run while macos and ubuntu
stayed green.
Before / After
Both crash units are replayed in
fuzz_crash_regressions.rs. Against the oldharness they reproduce the CI failures exactly:
— the same 1,283 bytes the nightly reported. After, all 11 replays pass.
The JS mechanism is reproducible on Linux: cancelling before dispatch rather
than sleeping gives the exact Windows signature.
Exit 130 (the assertion that passed in CI), no request at the server, and no
disconnect even after the original 2s budget — matching
serverAborted: false.With the fix the cancel waits on the server actually holding the request, so it
cannot precede dispatch; the elapsed bound is timed from the cancel so it no
longer folds in dispatch and connection setup; and a request that never arrives
now fails at that point with a clear message instead of as a mystery disconnect
timeout.
Also fixed on the same reporting path, found in review:
truncateslicedarbitrary fuzz output at a fixed 512 bytes and panicked whenever that offset
landed inside a multi-byte character, replacing a canary-leak message with an
unrelated backtrace. It now floors the cut to a character boundary
(
truncate_cuts_on_a_char_boundary).Risk
and context-free, while a real parser drops those characters only in certain
positions, and attribution is whole-script/whole-stderr. So it can excuse an
occurrence no parser would have produced. This is the same residual false
negative
script_explainsalready documents, accepted for the same reasons,and erring this way is the right direction — under-approximating is what
turns the nightly red on the detector's own dictionary.
keeps 1 KiB, pinned by
loosening_the_fuzz_cap_did_not_loosen_the_strict_path. Both remain absoluteagainst attribution (
attribution_does_not_relax_the_stderr_cap, sized offthe constant so a future raise cannot quietly turn it into a no-op), and
10 MB of library spam still fails.
26 configure no limit and take the 1 MiB default, so for them 4 KiB is a
deliberate flood bound and this class of false positive can recur. Documented
at the constant and in the threat model, with the fix named (give that target
an explicit
max_stderr_bytes).MAX_STDERR_BYTESispubbut#[doc(hidden)]and documented asunsupported; its value is unchanged in any case.
the request to reach the server and the abort to be observed, where before
a lost race could skip the first silently.
not yet observed green on
windows-latest; this PR's run is the first realtest of it.
Checklist
Validation
cargo test --features http_client(7607 passed), failpoints slice (19),cargo clippy --all-targets --all-features -- -D warnings,cargo fmt --check,scripts/tests(282), capability/workflow parity,check-okf,check-doc-links, and the fullavasuite (695 passed).cargo vetisunaffected — no dependency or lockfile change — and CI runs it. No benchmarks
apply: no product code changed.
Generated by Claude Code