startup: refuse an image instruction with fewer than three operands #2373
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2373
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2373/head"
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?
@ChazY11 on GitHub · 2026-11-25 14:04 UTC · original
ChazY11:startup/image-arity→main· +58 −0 · 5 files · 1 commits · merged 2026-11-25 14:17 UTCWhat
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.
`image()` reads vdata, an address and a descriptor, but it indexed them without checking how many operands it was given, so a shorter list reached `ops[1]` or `ops[2]` and came back as `translator crash in <op>: IndexError` instead of a refusal. Seven handlers share that body: `image_sample`, `image_sample_l`, `image_sample_lz`, `image_sample_b`, `image_get_lod`, `image_load` and `image_load_mip`. One guard, before the first index: if len(ops) < 3: raise Unsupported('image instruction with %d operands, expected at least 3' % len(ops)) Measured through the real `Stage` entry point: image_sample v[8:11], v0 before: translator crash in image_sample: IndexError after: image instruction with 2 operands, expected at least 3 image_load v[8:11] before: translator crash in image_load: IndexError after: image instruction with 1 operands, expected at least 3 The three-operand forms are untouched: `image_load v[8:11], v0, s[16:19]` still reports the descriptor operand, so the guard only replaces the crash. `tests/startup_gfx2hlsl_image_arity_check.py` is a new, focused check rather than an addition to `startup_gfx2hlsl_handler_arity_check.py`, which an in-flight PR is editing; it asserts the refusal at one and two operands for all seven forms and that the refusal is not `translator crash`. Registered in `CMakeLists.txt`, listed in the Linux CI check list and in AGENTS.md. Fail-first: removing exactly the guard fails the check with `('image_sample', ('v[8:11]',), [('translator crash in image_sample: IndexError', 'ps')])`, and restoring it returns exit 0. All 58 `tests/startup_gfx2hlsl_*_check.py` exit 0.