shader: refuse invalid destination codes and catch translator panics instead of crashing #135
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/135"
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?
Imported from uiliannn/VItoriaBr. Originally posted by INeedThis56 on 2026-11-29T02:46:53Z.
Summary
Two changes to
victory-shaderso that a shader the translator does not expect drops that program's draws instead of crashing the whole runtime.1. Fix an out-of-bounds panic in
ir.rs(unspill)A destination field that holds a scalar code of 128 or above (for example, a VOP3 compare
v_cmp_lt_f32 0x88, v1, 1.0) was accepted byadd_regs, because codes fromPARKEDup are valid for parked moves. It then indexedunspill's 128-entryusedtable out of bounds. Nowunspillleaves such a program as it is, andbuildrefuses any non-parked instruction that names a code ≥PARKED, returning the same"register range out of bounds"error that0xFFalready got. Codes 0–127 translate exactly as before. This also prevents a parked scalar from being given a code that the program itself names.2. Catch translator panics in
emit::translateA panic now becomes
ShaderError::Unsupported { what: PANICKED }, so it follows the existing "shader does not translate; its pipelines' draws are dropped" path. The panic message still reaches the panic hook. The retry switches (with_local_waves,with_local_waves_any,with_first_half_pairs) are now restored by a drop guard, so a caught panic cannot leave them enabled for later translations on that thread.How it was found
I mutated the GFX10 programs from the crate's own tests (bit flips, word replacement, insertion and deletion) and ran each one through
spill::build→structure→resource::track→io::raise→emit. Each mutation ran as wave64/wave32 compute and wave32 pixel, on 32- and 64-lane hosts.ir.rs:315.native_programs), with no panics.Testing
ir::tests::a_destination_past_the_machine_codes_is_refused(all 256 destination codes × wave32/wave64) andemit::lower::tests::a_panic_leaves_the_retry_switches_as_they_were.victory-shadersuite passes (190 tests), and clippy with the workspace lints reports nothing on the changed code.cargo xtask cion Windows before merging.Pull request closed