Repository navigation
psin_psch: reject overlapping PMAP blocks and duplicate sections - #7301
narekshaghoyandev wants to merge 2 commits into
Conversation
In tools/psin_psch.py, decode_pmap() verified block 0 and the last block bounds but never checked that consecutive blocks are non-overlapping/monotonic, and parse_psch_container() built a dict of sections that silently dropped duplicate tags. Reject overlapping PMAP blocks and duplicate section tags with ValueError, and add synthetic regression tests.
|
Checked
Neither new rejection fired on an intact container. The one existing validation failure in packs.rpf returned the same errors on both revisions. This covers 294 retail PMAP blocks alongside the PR’s synthetic rejection tests. CachyOS, CPU only, AI-assisted. Retested |
SirKingg
left a comment
There was a problem hiding this comment.
Thanks for the measurement across all 57 observed containers. Is there a format reference or additional aggregate evidence that PMAP rows must be non-overlapping and in table order, and that every section tag, including unknown tags, must be unique? Or is this validation intentionally limited to the observed subset?
Synthetic comparisons show a compatibility change: the base accepts disjoint PMAP blocks listed out of order, an empty block whose offset lies inside the preceding block, and repeated unknown TEST sections, while this revision rejects them. These examples do not establish that such inputs are valid.
AI-assisted review.
devnull34
left a comment
There was a problem hiding this comment.
Verified on Windows 11:
python -m unittest discover -s tests -p "test_psin*.py"passed all 84 tests (3.478s).- Validated
tools/psin_psch.py:decode_pmap()enforces monotonic, non-overlapping block bounds (block_offset < prev_end), raisingValueErroron corrupted/overlapping layouts.parse_psch_container()rejects duplicate section tags cleanly withValueError("Duplicate section tag").
- Whitespace clean (
git diff HEAD~1..HEAD --check).
|
Thank you @Kev-Ball for checking all 57 retail containers across Good catch on both compatibility edge cases — pushed
AI-assisted (Gemini). |
|
Tested 2eb93b8, clean vs main 976b3ec (re-run): all 4 tests in test_psin_psch.py pass, and the new overlap/duplicate-section test fails on clean main (silent first-section drop via dict overwrite). The consecutive-pair overlap scan is sufficient since out-of-order offsets overlap the previous block. Complements #7297's rejection table without case overlap. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested ec5b887 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
|
Tested
Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting; claimed in #8047. |
Claimed in the coordination issue as: #7049 (comment) (separate from #6260, which touches
check_report_path/main()).What and why
In
tools/psin_psch.py:decode_pmap()(lines 72–93) verified that block 1 starts at0x10, each block fits within0x10..first_section, and the last block ends atfirst_section, but never checked that consecutive blocks are non-overlapping (blocks[i]["offset"] >= blocks[i - 1]["offset"] + blocks[i - 1]["length"]). Overlapping or out-of-order blocks silently passed decoding.parse_psch_container()(line 241) mapped sections with{s["tag"]: s for s in rec["sections"]}, silently overwriting and ignoring duplicate sections with the same tag.Fix:
decode_pmap()withValueError.parse_psch_container()withValueError.test_rejects_overlapping_pmap_blocks_and_duplicate_sectionsintests/test_psin_psch.py.Tested
Linux x86_64 (Ubuntu 24.04 offline container, Python 3.12.3, CPU-only, no game files):
python3 -I tests/test_psin_psch.py -v— all tests passpython3 -I scripts/check_no_game_data.py tools/psin_psch.py tests/test_psin_psch.py— passpython3 -m compileall -q make_game.py tools tests— passAI-assisted: yes (Gemini)
Checklist
docs/design.md, with how it was confirmed.