Shader tests: malformed programs are refused, never panicked on #3712
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3712
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3712"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@davemathews12 on GitHub · 2026-11-30 04:27 UTC · original
davemathews12:test/malformed-shader-programs→main· +184 −0 · 1 files · 2 commits · openThe 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
cargo testpassed for the crates it touches: yes / noChecked for overlap
@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 intests/malformed_programs.rs.cargo xtask policydoesn't flag the new file (the one file it flags onmainisnative.rs, #4224).It catches what it says. With panics planted in the translator (not part of this PR):
structure(), more than 11 blocksemit(), more than 3 blocksThe 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:
HwStage::Cs, empty layout andused), soio::raiseand the lowering for vertex and pixel inputs and outputs, andresource::trackwith a real layout, aren't reached.catch_unwindturns 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.@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:
1a56b14now 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.@illuminatedfellow on GitHub · 2026-12-01 14:32 UTC · original
Ran on Linux:
malformed_programspasses onmain(5fabb46e), and the branch merges cleanly onto it. For extra coverage: fuzzing the translator on Linux (500,000 random and mutated programs throughir::buildto lowering, with debug assertions on) found no panics onmainas of Nov 30.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.