shader: pin call evidence code refs and mapped extent in dxcontainer_part_offsets_check #1821
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1828"
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:18:51Z.
Change
tests/dxcontainer_part_offsets_check.pyalready covers howtools/call_evidence.pyhandles part order and unmapped overlay bytes. It passes an emptymemorymap and only checks one valid, framed container. Because of that, the check did not notice when the tool reported the wrong code references, dropped the size check on size/pointer pairs, always reportedframed_dxil, or mapped bytes against the wrong section limit.This PR adds one case,
test_call_evidence_code_refs_size_match_and_virtual_extent. It builds a synthetic PE32+ image with one.rdatasection whose VirtualSize (0x180) is smaller than its SizeOfRawData (0x200). The section holds:STAT, at RVA 0x1020. Expected:framed_dxil=False, parts["STAT", "NOTE"], direct code ref0x2030.container()at RVA 0x1124, so it ends exactly at VirtualSize (0x124 + 0x5C = 0x180). Expected: reported, with direct code ref0x2000.size_code_refs=["0x2010"]andpointer_code_refs=["0x2020"].The case compares the full row list, so every key in each row is checked, including
direct_code_refs.tools/call_evidence.pyunless noted)1 <= count→0 <= countcount <= 128→count <= 127size <= len(data) - off→<_mapped_rva:rel + length > limit→>=_mapped_rva:min(SizeOfRawData, VirtualSize)→max(...)len(rts0) >= 24→> 24== sizecheckpointer_code_refsread frommemory[size_slot]direct_code_refsread frommemory[off](file offset, not RVA)framed_dxil=dxil_program(...)→Truepos >= 8→pos > 8continue→size_slot = 0off + 32 > len(data)→>=resource_inventory._parts_overlap:>→>=resource_inventory.dxil_program:delta >= 16→delta >= 0I applied each mutant to the local worktree, ran the check, and reverted it. No mutant was committed.
Verification
origin/mainat813045b3c13f7bad20d8577557b621ee869ccbbaout/pe-env)Evidence and follow-up
The fixture is synthetic and built inside the test. It uses no game files, dumps or third-party shaders.
These mutants are not pinned, and still survive:
count <= 128,size <= len(data) - off,off + 32 > len(data)andpos >= 8are boundaries at the 128-part limit or the start/end of the file. A test would need a container at file offset 0 or at the very end of the file, or a 128-part directory. I left them out to keep the case small.resource_inventory.dxil_programacceptsdelta >= 0. This is about DXIL program-header framing, notcall_evidence. It would fit better in a separate change that targetsdxil_program.The tool is not changed.
Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:32:14Z.
Review: COMMENTED
Reviewed at commit
64869e8e07364d50878f49263d2730dfc5887564(no P1/P2 defects found).Verification
git diff --check origin/main...HEAD: passpython -B tests/bidi_controls_check.py: pass (Checked 1320 tracked source, script and build/CI files: no bidirectional controls.)python -B tests/dxcontainer_part_offsets_check.py: pass (Ran 8 tests in 0.041s, OK)--preset dev):cmake --build --preset dev -- -j 8):0.18sctest --preset dev -R '^dxcontainer_part_offsets$' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.24s:dxcontainer_part_offsets0.16s)/O2(--preset release):cmake --build --preset release -- -j 8):0.18sctest --preset release -R '^dxcontainer_part_offsets$' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.25s:dxcontainer_part_offsets0.18s)python -B tests/dxcontainer_part_offsets_check.pyon mutatedtools/call_evidence.py, then restored cleanly):Misc_VirtualSizelimit in_mapped_rva(usedSizeOfRawData) -> failed as expected (rc=1)== sizecheck when matching size+pointer pairs inshader_containers-> failed as expected (rc=1)AI-assisted; commands listed were executed locally.