shader: pin call evidence code refs and mapped extent in dxcontainer_part_offsets_check #1821

Merged
Asimmimx merged 1 commit from upstream-pr/1828 into main 2026-11-24 19:32:52 +00:00
Asimmimx commented 2026-11-24 19:18:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T19:18:51Z.


Change

tests/dxcontainer_part_offsets_check.py already covers how tools/call_evidence.py handles part order and unmapped overlay bytes. It passes an empty memory map 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 reported framed_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 .rdata section whose VirtualSize (0x180) is smaller than its SizeOfRawData (0x200). The section holds:

  • a container whose DXIL part tag is renamed to STAT, at RVA 0x1020. Expected: framed_dxil=False, parts ["STAT", "NOTE"], direct code ref 0x2030.
  • the standard 0x5C-byte container() at RVA 0x1124, so it ends exactly at VirtualSize (0x124 + 0x5C = 0x180). Expected: reported, with direct code ref 0x2000.
  • a matching size/pointer pair at 0x1080/0x1088. Expected: reported with size_code_refs=["0x2010"] and pointer_code_refs=["0x2020"].
  • a pair at 0x10A0 that points at the same container but stores size + 1. Expected: not reported.
  • a 32-byte DXBC header with a part count of 0. Expected: no row.
  • a copy of the framed container in the raw slack at section offset 0x190, past VirtualSize. Expected: no row, because those bytes are not mapped.

The case compares the full row list, so every key in each row is checked, including direct_code_refs.

Mutant (tools/call_evidence.py unless noted) Existing check With the new cases
1 <= count → 0 <= count survived killed
count <= 128 → count <= 127 survived survived
size <= len(data) - off → < survived survived
_mapped_rva: rel + length > limit → >= survived killed
_mapped_rva: min(SizeOfRawData, VirtualSize) → max(...) survived killed
RTS0 len(rts0) >= 24 → > 24 killed killed
size/pointer pair: drop the == size check survived killed
pointer_code_refs read from memory[size_slot] survived killed
direct_code_refs read from memory[off] (file offset, not RVA) survived killed
framed_dxil=dxil_program(...) → True survived killed
pos >= 8 → pos > 8 survived survived
unmapped size slot: continue → size_slot = 0 killed killed
off + 32 > len(data) → >= survived survived
resource_inventory._parts_overlap: > → >= killed killed
resource_inventory.dxil_program: delta >= 16 → delta >= 0 survived survived

I applied each mutant to the local worktree, ran the check, and reverted it. No mutant was committed.

Verification

  • Base: origin/main at 813045b3c13f7bad20d8577557b621ee869ccbba
  • Windows 11 Pro 26300.9974, Python 3.12.10 (out/pe-env)
> python -B tests/dxcontainer_part_offsets_check.py
Ran 8 tests in 0.015s
OK

> python -B tests/docs_links_check.py
Self-test passed.
Checked 18 Markdown files and 369 links.

> python -B tests/bidi_controls_check.py
Self-test passed.
Checked 1320 tracked source, script and build/CI files: no bidirectional controls.

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) and pos >= 8 are 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_program accepts delta >= 0. This is about DXIL program-header framing, not call_evidence. It would fit better in a separate change that targets dxil_program.

The tool is not changed.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589539170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1828). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T19:18:51Z. --- ## Change `tests/dxcontainer_part_offsets_check.py` already covers how `tools/call_evidence.py` handles part order and unmapped overlay bytes. It passes an empty `memory` map 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 reported `framed_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 `.rdata` section whose VirtualSize (0x180) is smaller than its SizeOfRawData (0x200). The section holds: - a container whose DXIL part tag is renamed to `STAT`, at RVA 0x1020. Expected: `framed_dxil=False`, parts `["STAT", "NOTE"]`, direct code ref `0x2030`. - the standard 0x5C-byte `container()` at RVA 0x1124, so it ends exactly at VirtualSize (0x124 + 0x5C = 0x180). Expected: reported, with direct code ref `0x2000`. - a matching size/pointer pair at 0x1080/0x1088. Expected: reported with `size_code_refs=["0x2010"]` and `pointer_code_refs=["0x2020"]`. - a pair at 0x10A0 that points at the same container but stores size + 1. Expected: not reported. - a 32-byte DXBC header with a part count of 0. Expected: no row. - a copy of the framed container in the raw slack at section offset 0x190, past VirtualSize. Expected: no row, because those bytes are not mapped. The case compares the full row list, so every key in each row is checked, including `direct_code_refs`. | Mutant (`tools/call_evidence.py` unless noted) | Existing check | With the new cases | |---|---|---| | `1 <= count` → `0 <= count` | survived | killed | | `count <= 128` → `count <= 127` | survived | survived | | `size <= len(data) - off` → `<` | survived | survived | | `_mapped_rva`: `rel + length > limit` → `>=` | survived | killed | | `_mapped_rva`: `min(SizeOfRawData, VirtualSize)` → `max(...)` | survived | killed | | RTS0 `len(rts0) >= 24` → `> 24` | killed | killed | | size/pointer pair: drop the `== size` check | survived | killed | | `pointer_code_refs` read from `memory[size_slot]` | survived | killed | | `direct_code_refs` read from `memory[off]` (file offset, not RVA) | survived | killed | | `framed_dxil=dxil_program(...)` → `True` | survived | killed | | `pos >= 8` → `pos > 8` | survived | survived | | unmapped size slot: `continue` → `size_slot = 0` | killed | killed | | `off + 32 > len(data)` → `>=` | survived | survived | | `resource_inventory._parts_overlap`: `>` → `>=` | killed | killed | | `resource_inventory.dxil_program`: `delta >= 16` → `delta >= 0` | survived | survived | I applied each mutant to the local worktree, ran the check, and reverted it. No mutant was committed. ## Verification - Base: `origin/main` at `813045b3c13f7bad20d8577557b621ee869ccbba` - Windows 11 Pro 26300.9974, Python 3.12.10 (`out/pe-env`) ```text > python -B tests/dxcontainer_part_offsets_check.py Ran 8 tests in 0.015s OK > python -B tests/docs_links_check.py Self-test passed. Checked 18 Markdown files and 369 links. > python -B tests/bidi_controls_check.py Self-test passed. Checked 1320 tracked source, script and build/CI files: no bidirectional controls. ``` ## 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)` and `pos >= 8` are 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_program` accepts `delta >= 0`. This is about DXIL program-header framing, not `call_evidence`. It would fit better in a separate change that targets `dxil_program`. The tool is not changed. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 20:00:50 +00:00
tedin7 commented 2026-11-24 20:00:50 +00:00 (Migrated from github.com)

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

  • Linux checks:
    • git diff --check origin/main...HEAD: pass
    • python -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)
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev):
      • Build (cmake --build --preset dev -- -j 8): 0.18s
      • Test (ctest --preset dev -R '^dxcontainer_part_offsets$' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.24s: dxcontainer_part_offsets 0.16s)
    • Release /O2 (--preset release):
      • Build (cmake --build --preset release -- -j 8): 0.18s
      • Test (ctest --preset release -R '^dxcontainer_part_offsets$' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.25s: dxcontainer_part_offsets 0.18s)
  • Local mutation checks (python -B tests/dxcontainer_part_offsets_check.py on mutated tools/call_evidence.py, then restored cleanly):
    • Ignored Misc_VirtualSize limit in _mapped_rva (used SizeOfRawData) -> failed as expected (rc=1)
    • Dropped == size check when matching size+pointer pairs in shader_containers -> failed as expected (rc=1)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045980728 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1828#pullrequestreview-6045980728). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:32:14Z. **Review:** COMMENTED --- Reviewed at commit `64869e8e07364d50878f49263d2730dfc5887564` (no P1/P2 defects found). ### Verification - **Linux checks**: - `git diff --check origin/main...HEAD`: pass - `python -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) - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 8`): `0.18s` - Test (`ctest --preset dev -R '^dxcontainer_part_offsets$' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`0.24s`: `dxcontainer_part_offsets` `0.16s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 8`): `0.18s` - Test (`ctest --preset release -R '^dxcontainer_part_offsets$' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`0.25s`: `dxcontainer_part_offsets` `0.18s`) - **Local mutation checks** (`python -B tests/dxcontainer_part_offsets_check.py` on mutated `tools/call_evidence.py`, then restored cleanly): - Ignored `Misc_VirtualSize` limit in `_mapped_rva` (used `SizeOfRawData`) -> failed as expected (`rc=1`) - Dropped `== size` check when matching size+pointer pairs in `shader_containers` -> failed as expected (`rc=1`) AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1821
No description provided.