gfx2hlsl: refuse a scalar ALU source list shorter than the table template uses #2507
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2515"
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 R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T19:24:51Z.
What
Stage.scalarbuilds a scalar ALU expression withtext.format(*values), where theSCAentry spells its sourcesas
{0},{1}, … A source list shorter than the template uses leavesvaluestoo short andstr.formatraisesIndexError, which the single-shader path records astranslator crash in <op>: IndexErrorinstead of a refusalnaming the instruction — the class #2463 catalogues.
The arity guards merged in #2469 fire earlier in
lower()for their own subsets; this path reachesscalar()without passing one, so the short form of 36 two-source templates crashed. One guard before
text.formatcoversall of them, and it returns the same instruction-specific
Unsupportedshape the rest of the table uses.Refs #2463
Reproduction
Before the change, on
6d2d3bed:Fuzzing every two-source template with one source fewer gives 35
IndexErrors (s_add_i32 s_add_u32 s_and_b32 s_and_b64 s_andn2_b32 s_andn2_b64 s_ashr_i32 s_bfe_u32 s_lshl[1234]_add_u32 s_lshl_b32 s_lshr_b32 s_max_i32 s_max_u32 s_min_i32 s_min_u32 s_mul_hi_u32 s_mul_i32 s_nand_b32 s_nand_b64 s_nor_b32 s_nor_b64 s_or_b32 s_or_b64 s_orn2_b32 s_orn2_b64 s_pack_hh_b32_b16 s_sub_i32 s_sub_u32 s_xnor_b32 s_xnor_b64 s_xor_b32 s_xor_b64). Thethree-operand form is unaffected: every extra source is already refused with a well-formed message.
Checks
The whole
startup_gfx2hlsl_*family on this branch: 67 checks, 0 red.The two diagnostic paths, as asked
instruction into a refusal.
s_bfm_b32— it carries its ownexpected 3message, so it refuses with or without this guard. The controlexcludes it by name and asserts separately that it still refuses by its own message, rather than counting it as a
survivor and loosening the threshold.
Negative control
Changing
if len(srcs) < needed:toif False:makes the check exit 1; restoring it exits 0. That is the samein-place mutation the review reported, now part of the fixture.
Registration
CMakeLists.txt,AGENTS.mdand the Linux CI list each gain one entry next tostartup_gfx2hlsl_scalar_arity_check.py. No other behaviour changes: accepted instructions translate exactly asbefore, and only the refusing path is new.
Scope
One reviewable behaviour: a short source list is refused instead of crashing. The pointer-join and lane-mask claims
mentioned in #2463 stay with their authors; this branch does not touch them.
AI-assisted. Pure Python; no build or GPU needed. Verified on Windows 11 build 26300.9974.