Skip to content

skin_streams: require the dictionary page pointer at +8 - #2610

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
sds-228:skin-streams-dictionary-pointer
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
sds-228:skin-streams-dictionary-pointer

Conversation

@sds-228

@sds-228 sds-228 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: new BUILD item (ID pending) — #2300 (comment)

What and why

tools/skin_streams.py:resource_kind accepted a drawable dictionary with a null or non-system pointer at +8; the pinned rpf9-explorer's DrawableDictionaryCheckBytes requires a system pointer there. That made the Python census classify headers the decoder rejects and then walk them as dictionaries. This adds the +8 check; the other signature fields are unchanged.

Related: #2379 edits the adjacent fragment branch of the same function. This branch is based on main and does not include it.

Tested

  • python -I tests/test_skin_streams.py — 26 tests pass, including 3 new synthetic header tests. I watched the two negative tests fail before the fix.
  • python -m compileall -q make_game.py tools tests — clean.
  • Full standard-library sweep: 201 test files, 1 failure (tests/test_docs_design_rows.py), reproduced on clean main.
  • Counts-only run on my own package: data.rpf 2,322 resources / 3,222 skin meshes, unchanged before and after. No bytes, names or offsets in this report.
  • CPU only; no GPU, driver or game files in the diff.

AI-assisted: OpenCode (Big Pickle model).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No translator rule or contract-table change; this is a Python resource-header classifier.

AI-assisted (OpenCode).

@ricarmandoagent

Copy link
Copy Markdown

Checked 39f0cd70a7cbcb308a64e51d67b59da705c886bf (Linux, Python 3.15.2, no game files).

$ python3 -m compileall -q make_game.py tools tests          # exit 0
$ python3 -I tests/test_skin_streams.py                     # Ran 26 tests ... OK
$ git diff --check main...HEAD                              # exit 0
$ python3 -I tests/test_docs_design_rows.py                 # FAILED (failures=3) also on clean main (pre-existing)

Negative control: with tools/skin_streams.py from main and the new tests kept, the two negative tests
fail (AssertionError: 'dictionary' is not None) and the positive test still passes, so the tests distinguish
the fix.

Verified the requirement against the pinned submodule source (third_party/rpf9-explorer at
e2939175c36a02d6ed25fa2c217b9d6ddcb8b516, Core/RageModelDecoder.cs:101-107): DrawableDictionaryCheckBytes
requires a system pointer at +8, +32 and +48 before the count checks, and its SystemPointer is
0x50000000 <= p < 0x50000000 + MaxSystemBytes with MaxSystemBytes = 32 * 1024 * 1024. The Python sys_ptr
bounds are identical; boundary probe on the patched resource_kind:

+8 null 0x0        -> None       +8 0x50000000          -> dictionary
+8 0x12345678      -> None       +8 0x51ffffff (last)   -> dictionary
                                 +8 0x52000000 (past)   -> None

The added field matches the C# header check exactly; the remaining C# tail check (first child pointer at the
+48 offset) is still absent from resource_kind, but that is pre-existing and not claimed here.

Verdict: passes.

AI-assisted review.

@ricarmandoagent

Copy link
Copy Markdown

Reviewed 39f0cd70a7cbcb308a64e51d67b59da705c886bf against base 49475796 (Bazzite 45 / Linux 7.3.4, Python 3.15.2, CPU only, no game files).

$ python3 -m compileall -q make_game.py tools tests        # exit 0
$ python3 -I make_game.py --help                           # exit 0
$ python3 -I tests/test_skin_streams.py                    # Ran 26 tests ... OK
$ git diff --check origin/main...HEAD                      # exit 0

Negative control: with tools/skin_streams.py from main and the new tests kept, exactly the two new
negative tests fail (AssertionError: 'dictionary' is not None); the positive test passes on both, as it must.

The requirement is checked against the pinned decoder in the submodule, not taken from the body.
third_party/rpf9-explorer is at e2939175 (the e293917 pin), and Core/RageModelDecoder.cs:101-112
(DrawableDictionaryCheckBytes) returns -1 unless SystemPointer holds at +8, +32 and +48;
SystemPointer (:263) is 0x50000000 <= p < 0x50000000 + MaxSystemBytes with MaxSystemBytes = 32 MiB
(:56) — the same window as sys_ptr/MAX_SYS here. The added +8 term is exactly the missing condition,
and nothing else in the branch changed.

Independent probes of ss.resource_kind on hand-built 192-byte headers:

  • +8 at the sys_ptr edges: 0x50000000 and 0x51fffff8 -> dictionary; 0x52000000, 0x4fffffff,
    0x12345678, 0 -> None.
  • A rejected dictionary cannot fall through into another kind: with a null or non-system +8, every other
    dictionary field valid and drawable-looking +16/+80/+168 added, the result is still None (the
    dictionary's +48 pointer makes finite_bounds(+48) fail, and the fragment branch needs +8 too).
  • A synthetic drawable from the test builder still classifies drawable; a synthetic fragment header still
    classifies fragment, so neither neighbouring branch is disturbed.

Limitations: the body's real-package count ("2,322 resources / 3,222 skin meshes, unchanged") needs the game
files, so I did not verify it and cannot from this machine. The claim that tests/test_docs_design_rows.py
fails on clean main matches what I see: the same 3 assertion failures on a pristine origin/main tree
(git archive), and this diff touches neither docs/ nor that test.

Nit (non-blocking, pre-existing): the Python branch is not full parity with the pinned function. It does not
resolve the +48 pointer array and require the first child to be a SystemPointer, as
DrawableDictionaryCheckBytes does, so a header that the decoder rejects can still be labelled dictionary;
it is then skipped by s_off/check in drawable_offsets, so nothing is walked. The test docstring's
"follow the pinned ... DrawableDictionaryCheckBytes" is a little stronger than what is implemented.

Verdict: LGTM.

AI-assisted review.

@Jadiac5

Jadiac5 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 39f0cd7 on Windows 11, Python 3.12.10: pass

  • Real-archive run, head against merge base 4947579: python -I tools/skin_streams.py <archive> --json out.json on data.rpf, core_restofworld.rpf, story000_restofworld.rpf and shared_minigame000.rpf of my own copy. Exit code 0 in all eight runs.
  • The JSON reports are byte-identical between base and head on all four archives (784, 1,371, 286 and 1,336 bytes).
  • data.rpf: 2,402 candidates, 2,322 resources, 80 skipped, 3,222 meshes, 3,854,484 vertices, before and after. The 2,322 and 3,222 in the description match.
  • core_restofworld.rpf: 1,024 candidates, 883 resources, 141 skipped, 1,138 meshes, before and after.
  • So the added check at tools/skin_streams.py:119 rejects nothing on these four archives: no regression, but its reject branch is not reached by real data here. Only the synthetic tests cover it.
  • Timings unchanged (data.rpf 15.6 s base, 14.7 s head).
  • Not done: the other archives; no unit tests rerun (already reported by others at this head).

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants