shader: pin candidate container field refusals in sgd5_effects_check #1829
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1836"
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 Asimmimx on 2026-11-24T19:20:28Z.
Change
tests/sgd5_effects_check.pybuilt every program record with the same wrapper,reflection block and DXIL header. As a result, most of the checks that
tools/sgd5_effects.pyapplies to one candidate container were never run witha value that fails them. I applied single-point mutants to the tool by hand and
ran the existing check after each one. These ten mutants passed the existing
check:
tools/sgd5_effects.py)read_program:12 < size->12 <= size(accept an empty compressed stream)read_program: reflection length9 + 24 * (registers + buffers)->9 + 24 * registersread_program: dropreflection != repeatedinspect_container: dropnot decoder.eofinspect_container: dropdecoder.unused_datainspect_container:len(blob) != program.decoded->>inspect_container:len(dxil) < 24->< 0inspect_container: dropmagic != b"DXIL"inspect_container:payload_offset < 16->< 15inspect_container:payload_size < 4->< 0The
program()helper gets optionaldxil,pack,declaredandreflectionarguments. Their defaults produce the same bytes as before, and theexisting cases do not change. The new
test_container_fieldsplaces one programin the PS table of a one-effect group and selects it. The cases are:
9 + 2 * 24 = 57 bytes. The candidate digest must match.
reflection blockerror.boundederror.without a final block (
Z_SYNC_FLUSH), and a decoded size that is one bytetoo long: each gives
container disagrees.Truncatederror.DXBC, a payload offset of 15 and a payload size of 3: eachgives
invalid header. The part still declares eight words (32 bytes), so8 + 15 + 8 = 31 and 8 + 16 + 3 = 27 both fit. Only the field under test is
wrong.
Each refusal is matched by its message, so a case cannot pass because a later
check rejects the input. For example, without the size check the empty stream
reaches the decoder and fails as
container disagrees. Theboundedregexdoes not match that message.
Verification
Based on
origin/main813045b3c1. Windows 11 Pro26300.9974, Python 3.12.10.
For the mutation table, I applied each mutant to
tools/sgd5_effects.pyand ranpython -B tests/sgd5_effects_check.py. Then I restored the file. On theunmodified tool, all ten mutants fail the new test and the check passes.
Evidence and follow-up
All inputs are synthetic and built inside the check. No game files are used.
The same probe found other mutants that the check still does not catch. I left
them out to keep this PR to one behavior. Another contributor can pick them up:
candidates: theSGD5group magic check can be removed, andgroup_start + 32 <= arrayscan become+ 31. Neither change fails the check.before // 36->// 35,after // 36->// 35,and either half of
before and (before < 36 or effect_count == 1)can bedropped without failing the check.
Cursor.name: the minimum length (2), the trailing NUL and the printable rangehave no rejecting case.
validate_name_block: droppingtail[-1], the minimum length 5 orstarts != 1->starts < 1(two sized blocks that both end at the boundary)are not caught.
32 <= decodedis caught for a selected program becauseparts()rejects acontainer shorter than 32 bytes, but not for an unselected table entry.
on one side, or not at all.
The tool is not changed.
Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:33:18Z.
Review: COMMENTED
Reviewed
tests/sgd5_effects_check.pyat commit6dfabe097ff6ee43c18362636365371f373cbf25againsttools/sgd5_effects.py(read_programandinspect_container). All new positive and negative container-field assertions pin real reflection-length, deflate framing, decoded-size, and DXIL header bounds; clean-room and title-neutral, 0 P1/P2 defects found.Linux verification
git diff --check origin/main...HEAD— passedpython -B tests/bidi_controls_check.py— passed (1320 files checked)python -B tests/sgd5_effects_check.py -v— 4/4 tests passed (0.243s)Windows Server 2025 verification (Build 26100, MSVC 14.44.35207 + D3D12 WARP)
--preset dev):ctest --preset dev -R '^sgd5_effect_candidates$' --parallel 6 --no-tests=error --output-on-failure— 1/1 passed (0.35s)/O2(--preset release):ctest --preset release -R '^sgd5_effect_candidates$' --parallel 6 --no-tests=error --output-on-failure— 1/1 passed (0.35s)Local mutation checks
tools/sgd5_effects.pyto dropnot decoder.eof or decoder.unused_dataininspect_container:python -B tests/sgd5_effects_check.pyfailed (rc=1, killed).tools/sgd5_effects.pyto relaxpayload_offset < 16 or payload_size < 4to< 15/< 3:python -B tests/sgd5_effects_check.pyfailed (rc=1, killed).AI-assisted; commands listed were executed locally.