startup: refuse a short operand list in the scalar ALU handlers #2461
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2469"
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-25T17:36:53Z.
Eleven of the 44
SCAentries readops[1]without checking the count, so a short list came back astranslator crash in <op>: IndexError— the batch translator's marker for a translator defect, not for textit does not lower.
s_add_u32with no operands was the shortest repro.What changed
Stage.scalaris the single entry for the wholeSCAtable, so the guard is one check rather than eleven:op_s_bfm_b32keeps its own body (it folds constant masks and inspectsops[0]for them0destination), soit gets the same check in place.
s_movk_i32keeps its existing exact check for the immediate it folds.s_cselect_b32,s_abs_i32,s_bcnt1_i32_b32,s_addk_i32and thes_cmp*forms already refused thesecorrectly and are unaffected.
The check
tests/startup_gfx2hlsl_scalar_arity_check.pycovers, for all 44SCAentries, one accepted shape and bothshort forms, plus the refusal text for three of them and a negative control that loads the translator with
the guard removed:
Guard removal proof, one at a time:
Registered in
CMakeLists.txt(visible asstartup_gfx2hlsl_scalar_arityinctest -N), in the LinuxRun Python checkslist, and inAGENTS.md.Verification
tests/startup_gfx2hlsl_*_check.pyexit 0 on this branch;ctest --preset dev -R startup_gfx2hlslpasses 131/131 (658 s), so no accepted form changed;AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T17:42:39Z.
One addition that every other open PR here has and mine did not: a
docs/experiments.mdentry. I checked beforewriting it — my two earlier merged refusal PRs (#2360, #2373) carried no docs change, so this is not a gate,
but four of the five refusal/lowering PRs open right now document their rule, and the rule behind these count
checks was only in the code comments.
bbd4b69eadds one section todocs/experiments.md: whytranslator crash in <op>: <ExcType>is the wrongoutcome for a short operand list (
Stage.translaterecords it as a translator defect andrefusals_reportgroups by that text), which four entry points now refuse instead, and which check pins each. No behaviour
change;
tests/docs_links_check.pypasses (19 files, 466 links) and the scalar check still exits 0 on the head.If you would rather keep the docs out of this PR, say so and I will drop the commit; it is separable.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T17:59:03Z.
Review-cost note, not a request: #2396 (5 handlers), #2408 (7 image forms) and this one (44
SCAentries) are allgreen and independent, and all three are refusal-only. If the size of this one is the reason it is waiting, it
splits cleanly into the 18 entries that actually crashed (
s_add_u32,s_sub_u32,s_mul_i32,s_and_b32,s_or_b32,s_xor_b32,s_lshl_b32,s_lshr_b32,s_ashr_i32,s_min_i32,s_max_u32,s_mov_b32,s_not_b32,s_brev_b32,s_mul_hi_u32, pluss_bfm_b32in its own body) and the rest, which thesingle
Stage.scalarguard covers for free but which never produced the marker. I can reduce the fixture to the18 and drop the docs commit to make a smaller first merge, and follow with the remainder.
The measurements behind it, in one place, so nothing needs re-running to decide:
One limitation I should state rather than leave implied: this machine cannot complete the full C++ build
(
archive_reader.exeand friends fail in DXC withunable to create compilation: AccessDenied, unrelated toany branch here), so my local evidence is limited to the pure-Python and
gfx2hlslside. The PRs arePython-only and CI builds them on the runners.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:27:58Z.
Self-review of the table this PR adds to
docs/experiments.md, since a table that looks exhaustive is the easiestplace to mislead. I checked it against every operand-count refusal in the tree on
c887a65a:So the classification holds, but three refusal sites (
saveexec,wrexec,scalar select) are reachable andunnamed. Nothing is wrong with the behaviour they describe — all three already refuse — the question is only whether
the table should enumerate them.
Two readings, and I would rather you pick than guess:
translator crash in <op>: <ExcType>— then it iscorrect as written, and I should add one sentence saying so explicitly, because "four rows" reads like "four
sites" to someone comparing against the source.
saveexec,wrexecandscalar selectbelong in it, and I will extend it.
My own preference is (1) plus the sentence, since the crash is what the section is about and a longer table invites
the reader to think the list is the whole of the refusal surface. Say which and I will adjust; the docs commit is
separable from the guard commit either way.
While here, one measurement that supports the section's claim that a short operand list is the failure mode and not
a hypothetical: with the
Stage.scalarguard removed,s_add_u32with 0 operands raisesIndexErrorfrom%s with %d operands, expected 2→opsindexing, i.e. exactly thetranslator crash in s_add_u32: IndexErrorline the table's third column records.
AI-assisted.