Skip to content

fix(fuzzer): parse a Rust type past the semicolon inside an array - #766

Merged
nihalpasham merged 4 commits into
NVIDIA:mainfrom
alejandro-soto-franco:fix/fuzzer-adapter-array-types
Aug 10, 2026
Merged

nihalpasham merged 4 commits into
NVIDIA:mainfrom
alejandro-soto-franco:fix/fuzzer-adapter-array-types

Conversation

@alejandro-soto-franco

Copy link
Copy Markdown
Contributor

The adapter captured Rust types with [^;]+, which reads a type as everything up to the first semicolon. An array type carries a semicolon inside its brackets, so [u128; 1] was captured as [u128.

Summary

Adds split_type_at_semicolon, uses it at both sites that captured a type, and raises composite_count from 0 to 3 now that the adapter survives what that produces.

Changes

  • crates/fuzzer/tools/mir_generator.py: split_type_at_semicolon, tracking bracket depth over ( and [ in the idiom split_args already uses. The type RET = ..; insertion anchor and the local-declaration scan both use it. composite_count = 3 in TINY_CONFIG, and the module docstring no longer says the generated program is scalar-only.
  • crates/fuzzer/README.md: refreshes the two quoted --start 0 --count 2 transcripts, which the config change makes stale.

Rationale

The insertion anchor matched type RET = [^;]+;. On an array return type it stopped mid type and left the remainder stranded after the inserted declarations:

type RET = [u128;
        let __rl_dump0: (u64,); 1];

rustc reads that as a let statement in expression position and refuses the case. The local-declaration scan truncated the same way, so an array-typed local was recorded as [i32 and reported under that truncated name when the trace API declined to hash it. Since an UNSUPPORTED reason is how the next widening of the trace API gets chosen, a truncated type name misdirects that choice.

Neither fault was reachable as checked in. No fn0 signature in seeds 300-499 contains a semicolon at composite_count = 0, because that setting keeps tuples and arrays out of the generated program entirely. The knobs above it in TINY_CONFIG (tuple_max_len, array_max_len) have been inert.

That is the reason to raise it. The fuzzer's most valuable find so far, the silent miscompile behind #393, lived in aggregate constants with padding, and the configuration excludes that whole space. adt_count stays at 0: the adapter extracts one function and carries no user-defined type definitions with it, so a generated Adt20 fails to resolve. Widening to ADTs is a separate change.

Validation

RTX 5060 Laptop GPU, compute capability 12.0, CUDA 13.3, driver 610.43.03.

Seeds 300-359, changing only the adapter, both runs at the composite_count = 3 and adt_count = 0 this PR ships:

before:  PASS=40  UNSUPPORTED=18  COMPILE_FAIL=2
after:   PASS=42  UNSUPPORTED=18  COMPILE_FAIL=0

Both failures in the before column were the stranded-type syntax error rather than a backend refusal, and both become passing device runs.

Seeds 1000-1999 on the fixed adapter at the same configuration:

PASS=673  UNSUPPORTED=320  COMPILE_FAIL=7  MISMATCH=0

Six of those seven are #765. The seventh is a separate backend fault that llc rejects, reported separately.

Aggregate reach over the same 60 seeds, counting programs whose locals or return type hold an array or a multi-field tuple:

composite_count = 0:   0 of 60 seeds
composite_count = 3:  25 of 60 seeds, of which 7 compile and run on the device

The remaining 18 are UNSUPPORTED, refused at the trace boundary because a dump site or return position holds the aggregate itself. Hashing an aggregate by its scalar leaves would convert most of them and is the obvious next step.

The truncation fix is visible in the reason text, which now names the whole type:

before:  UNSUPPORTED [adapter] unsupported dumped type for Stage 2 adapter: [i8
after:   UNSUPPORTED [adapter] unsupported dumped type for Stage 2 adapter: [i8; 1]

#765 was surfaced by that sweep and the checked-in configuration cannot reach it.

The adapter captured types with `[^;]+`, which reads a Rust type as
everything up to the first semicolon. An array type carries a semicolon
inside its brackets, so `[u128; 1]` was captured as `[u128`.

Two sites suffered. The anchor that inserts the dump-local declarations
matched `type RET = [^;]+;`, so on an array return type it stopped mid
type and left the remainder stranded after the inserted declarations:

    type RET = [u128;
        let __rl_dump0: (u64,); 1];

which rustc reads as a statement and refuses. The local-declaration scan
truncated the same way, so an array-typed local was recorded as `[i32`
and reported under that name when the trace API declined to hash it.

split_type_at_semicolon tracks bracket depth over `(` and `[` in the
idiom split_args already uses, and stops at the first semicolon outside
them. Both sites now share it.

Neither fault was reachable with `composite_count = 0`: no signature in
seeds 300-499 contains a semicolon. That setting is what kept the whole
composite space out of the fuzzer, including the aggregate constants that
issue NVIDIA#393 turned out to live in. It is raised to 3 here, with
`adt_count` left at 0 since the adapter extracts one function and carries
no user-defined type definitions with it.
When the adapted function carries dump locals but the `type RET = ..;`
alias (or its depth-0 terminating `;`) cannot be found, the adapter
silently skipped inserting the declarations. The rewritten dump calls
then referenced undeclared locals, rustc rejected the case, and
run_seed.py misreported the adapter's own parse gap as a backend
COMPILE_FAIL. Raise SystemExit instead, in the file's existing style,
so the seed reports as UNSUPPORTED [adapter] with the real reason.
run_seed.py printed absolute log paths, so every printed summary (and
any transcript quoted from it) was tied to one particular checkout,
while the README's quoted transcripts showed repo-relative paths that
the tool never actually printed. Render the paths relative to the repo
root at every print site and in summary.jsonl, so the quoted
transcripts are the literal output of the quoted commands.
Raising composite_count to 3 changes what every seed generates, which
staled the README's seed-specific claims: seed 192 no longer produces
the quoted two-dump-site case (it is now UNSUPPORTED, dumping
[i128; 1]), and seed 162 no longer reproduces the checked-in
generated_case.rs (it now dumps a (bool,) tuple and adapts to nothing).

Re-anchor the two-dump-site illustration on seed 33, which under the
shipped config emits exactly the previously quoted dump sites and
passes CPU/GPU comparison on sm_120. Keep the checked-in snapshot as
is, since no nearby seed under the new config calls libdevice and the
fmaf64 coverage is why it exists; state in the README and in its header
that it predates the composite config and cannot be regenerated from
its seed. Quote the seed 0/1 transcript from a real run: it needs
--keep-going, because seed 0's UNSUPPORTED otherwise stops the run
before seed 1, and its seed 0 line carries the log path.
@nihalpasham nihalpasham added bug Something isn't working QoL-improvement Quality-of-life improvement; not a correctness fix fuzzer Fuzzing infrastructure (rustlantis, difftest) labels Aug 10, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Verified:

  • the depth-0 semicolon fix and reproduced your 300-359 sweep on sm_120: PASS=42, COMPILE_FAIL=0, no mismatches.

Pushed three follow-ups on the branch:

  • the adapter now fails loudly when the type RET anchor is missing, run_seed.py prints repo-relative paths so the README transcripts are literal output, and
  • the seed-specific prose is re-anchored on the shipped config.

One note: the two-seed transcript needs --keep-going, since seed 0's UNSUPPORTED otherwise stops the run; the README now quotes that command.

@nihalpasham
nihalpasham merged commit f501110 into NVIDIA:main Aug 10, 2026
36 checks passed
@alejandro-soto-franco
alejandro-soto-franco deleted the fix/fuzzer-adapter-array-types branch September 9, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fuzzer Fuzzing infrastructure (rustlantis, difftest) QoL-improvement Quality-of-life improvement; not a correctness fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants