startup: refuse an image instruction with fewer than three operands #2365
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2373"
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-25T14:04:31Z.
What
image()reads vdata, an address and a descriptor, but indexed them without checking how many operands it was given, so a shorter list reachedops[1]orops[2]and came back astranslator crash in <op>: IndexError— the batch translator's marker for a translator defect, not for an instruction it does not lower — and the single-shader path does not catch it at all. Seven handlers share that body:image_sample,image_sample_l,image_sample_lz,image_sample_b,image_get_lod,image_load,image_load_mip.One guard, before the first index:
Measured through the real
Stageentry pointThe three-operand forms are unchanged:
image_load v[8:11], v0, s[16:19]still reportsdescriptor operand s[16:19] holds None, so the guard replaces the crash and nothing else.Fail-first
Removing exactly the guard:
restoring it returns
startup gfx2hlsl image arity: 7 forms refused at 1 and 2 operands, exit 0.The check is a new file, deliberately
tests/startup_gfx2hlsl_image_arity_check.pyis separate fromtests/startup_gfx2hlsl_handler_arity_check.py, which an in-flight PR is editing — two PRs adding a helper at the same anchor would conflict in that hunk for no benefit. The new file asserts the refusal at one and two operands for all seven forms, and that the refusal is nottranslator crash …, so a handler that starts raising something else fails here too. It is registered inCMakeLists.txt, listed in the Linux CI check list (.github/workflows/windows.yml) and inAGENTS.md.Verification
exit 0, and all 58
tests/startup_gfx2hlsl_*_check.pyexit 0 on this branch. The failing set of alltests/startup_*_check.pyrun with no arguments is identical on this branch and onmain(51 each, none added or removed), so the only checks that move are the ones this PR touches — most of those need a renderer and fail the same way on both.What this does not touch
The handlers that still index operands without a count check (
v_cndmask_b32,v_mov_b32,v_cvt_i32_f32,s_bitcmp*, …) are unchanged: they do not share a body, so each needs its own line and its own accepted-form fixture. Same for the buffer bodies, which #2360 covers.AI-assisted.