Shader tests: malformed programs are refused, never panicked on #3712

Open
github-bot wants to merge 2 commits from github-bot/gh-3712 into main AGit
Owner

@⁠davemathews12 on GitHub · 2026-11-30 04:27 UTC · original
davemathews12:test/malformed-shader-programs → main · +184 −0 · 1 files · 2 commits · open

The title hands us its shader bytes at pipeline creation, and a panic on that thread ends the game where an error lets the runtime fall back. The ISA census (#673) puts each opcode alone in a straight program; this test puts them together: instructions drawn from a dictionary of every encoding the decoder and ir::build accept alone, in random order, with branches of every kind to random instruction boundaries and EXEC narrowed and widened at random, wave32 and wave64, through spill::build, structure, resource::track, io::raise and emit. Of 5,000 such programs, 92 % build, 12 % reach emit and 3 % come out as DXIL.

Seeded and synthetic (nothing from a title): 300 programs per run, under a second in a debug build. A failure lists the seeds, and VICTORY_MALFORMED_SEED= replays one; VICTORY_MALFORMED_PROGRAMS sets the count.

Checked: a panic planted in structure() (more than 11 blocks) fails it, 80 of 300 programs, seeds listed. With VICTORY_MALFORMED_PROGRAMS=200000 in release it passes (57 s): no panic found in main today, nor in a debug sweep with overflow checks of the same kind, which also gave 300,000 random inputs to each victory-formats decoder (BCPack, XMA, texture layouts) without one.

Fixes #

What it changes

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing):
  • Before:
  • After:
  • For shader changes, the wave sizes tested (32 and/or 64 lanes):
  • cargo test passed for the crates it touches: yes / no

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #
**@⁠davemathews12** on GitHub · 2026-11-30 04:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3712) `davemathews12:test/malformed-shader-programs` → `main` · +184 −0 · 1 files · 2 commits · open The title hands us its shader bytes at pipeline creation, and a panic on that thread ends the game where an error lets the runtime fall back. The ISA census (#673) puts each opcode alone in a straight program; this test puts them together: instructions drawn from a dictionary of every encoding the decoder and ir::build accept alone, in random order, with branches of every kind to random instruction boundaries and EXEC narrowed and widened at random, wave32 and wave64, through spill::build, structure, resource::track, io::raise and emit. Of 5,000 such programs, 92 % build, 12 % reach emit and 3 % come out as DXIL. Seeded and synthetic (nothing from a title): 300 programs per run, under a second in a debug build. A failure lists the seeds, and VICTORY_MALFORMED_SEED=<seed> replays one; VICTORY_MALFORMED_PROGRAMS sets the count. Checked: a panic planted in structure() (more than 11 blocks) fails it, 80 of 300 programs, seeds listed. With VICTORY_MALFORMED_PROGRAMS=200000 in release it passes (57 s): no panic found in main today, nor in a debug sweep with overflow checks of the same kind, which also gave 300,000 random inputs to each victory-formats decoder (BCPack, XMA, texture layouts) without one. <!-- Thanks for the pull request. Please label it (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests, plus the area labels), or put the label in the title, like [pr-fix]. --> Fixes # ## What it changes <!-- What was wrong, and what this does about it. --> ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): - Before: - After: - For shader changes, the wave sizes tested (32 and/or 64 lanes): - `cargo test` passed for the crates it touches: yes / no ## Checked for overlap - [ ] I searched the open pull requests for the same issue and for the files this touches. Related: #
The title hands us its shader bytes at pipeline creation, and a panic on
that thread ends the game where an error lets the runtime fall back. The
ISA census (#673) puts each opcode alone in a straight program; this test
puts them together: instructions drawn from a dictionary of every
encoding the decoder and ir::build accept alone, in random order, with
branches of every kind to random instruction boundaries and EXEC
narrowed and widened at random, wave32 and wave64, through spill::build,
structure, resource::track, io::raise and emit. Of 5,000 such programs,
92 % build, 12 % reach emit and 3 % come out as DXIL.

Seeded and synthetic (nothing from a title): 300 programs per run, under
a second in a debug build. A failure lists the seeds, and
VICTORY_MALFORMED_SEED=<seed> replays one; VICTORY_MALFORMED_PROGRAMS
sets the count.

Checked: a panic planted in structure() (more than 11 blocks) fails it,
80 of 300 programs, seeds listed. With VICTORY_MALFORMED_PROGRAMS=200000
in release it passes (57 s): no panic found in main today, nor in a debug
sweep with overflow checks of the same kind, which also gave 300,000
random inputs to each victory-formats decoder (BCPack, XMA, texture
layouts) without one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 04:28:34 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 17:55 UTC · original

Checked on Windows 11 (Rust 1.98.1, pinned), applied on current main (84bd61e2); it cherry-picks cleanly and builds against today's API. The test passes in 0.57 s in a debug build (three runs), and Clippy reports nothing in tests/malformed_programs.rs. cargo xtask policy doesn't flag the new file (the one file it flags on main is native.rs, #4224).

It catches what it says. With panics planted in the translator (not part of this PR):

planted panic result
structure(), more than 11 blocks fails: 80 of 300 programs, seeds listed (the same 80 you got)
emit(), more than 3 blocks fails: 15 of 300
none passes

The stage numbers hold. With throwaway counters, 5,000 programs (release, 1.2 s): 4,622 built (92 %), 623 reached emit (12 %), 159 came out as DXIL (3 %). The default 300: 268, 40 and 10.

Two limits that might be worth a line in the module doc, so nobody reads more into a green run:

  • Every program is a compute program (HwStage::Cs, empty layout and used), so io::raise and the lowering for vertex and pixel inputs and outputs, and resource::track with a real layout, aren't reached.
  • catch_unwind turns a panic into a failure, but a program that sends a stage into an endless loop would hang the test rather than fail it, and a stack overflow would abort the process.
**@⁠babuakhil** on GitHub · 2026-11-30 17:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3712#issuecomment-7287054170) Checked on Windows 11 (Rust 1.98.1, pinned), applied on current `main` (`84bd61e2`); it cherry-picks cleanly and builds against today's API. The test passes in 0.57 s in a debug build (three runs), and Clippy reports nothing in `tests/malformed_programs.rs`. `cargo xtask policy` doesn't flag the new file (the one file it flags on `main` is `native.rs`, #4224). **It catches what it says.** With panics planted in the translator (not part of this PR): | planted panic | result | |---|---| | `structure()`, more than 11 blocks | fails: 80 of 300 programs, seeds listed (the same 80 you got) | | `emit()`, more than 3 blocks | fails: 15 of 300 | | none | passes | **The stage numbers hold.** With throwaway counters, 5,000 programs (release, 1.2 s): 4,622 built (92 %), 623 reached `emit` (12 %), 159 came out as DXIL (3 %). The default 300: 268, 40 and 10. Two limits that might be worth a line in the module doc, so nobody reads more into a green run: - Every program is a compute program (`HwStage::Cs`, empty layout and `used`), so `io::raise` and the lowering for vertex and pixel inputs and outputs, and `resource::track` with a real layout, aren't reached. - `catch_unwind` turns a panic into a failure, but a program that sends a stage into an endless loop would hang the test rather than fail it, and a stack overflow would abort the process.
As checked on Windows by babuakhil on #3712: compute programs with an
empty layout only (no vertex or pixel paths, no real root layout), and an
endless loop or a stack overflow is not reported as a failing seed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠davemathews12 on GitHub · 2026-11-30 18:18 UTC · original

Thanks @⁠babuakhil, that's the Windows check this needed, and your stage counts match mine exactly (4,622 / 623 / 159 of 5,000). Good point on the limits: 1a56b14 now says in the module doc that it reaches only compute programs with an empty layout, and that an endless loop or stack overflow isn't reported as a failing seed.

**@⁠davemathews12** on GitHub · 2026-11-30 18:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3712#issuecomment-7287654266) Thanks @⁠babuakhil, that's the Windows check this needed, and your stage counts match mine exactly (4,622 / 623 / 159 of 5,000). Good point on the limits: 1a56b14 now says in the module doc that it reaches only compute programs with an empty layout, and that an endless loop or stack overflow isn't reported as a failing seed.
Author
Owner

@⁠illuminatedfellow on GitHub · 2026-12-01 14:32 UTC · original

Ran on Linux: malformed_programs passes on main (5fabb46e), and the branch merges cleanly onto it. For extra coverage: fuzzing the translator on Linux (500,000 random and mutated programs through ir::build to lowering, with debug assertions on) found no panics on main as of Nov 30.

**@⁠illuminatedfellow** on GitHub · 2026-12-01 14:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3712#issuecomment-7314418391) Ran on Linux: `malformed_programs` passes on `main` (5fabb46e), and the branch merges cleanly onto it. For extra coverage: fuzzing the translator on Linux (500,000 random and mutated programs through `ir::build` to lowering, with debug assertions on) found no panics on `main` as of Nov 30.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3712/head:github-bot/gh-3712'
git switch 'github-bot/gh-3712'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3712'
git switch 'github-bot/gh-3712'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3712'
git switch 'github-bot/gh-3712'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3712'
git switch 'main'
git merge --squash 'github-bot/gh-3712'
git switch 'main'
git merge --ff-only 'github-bot/gh-3712'
git switch 'main'
git merge 'github-bot/gh-3712'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3712
No description provided.