OLD-7481: restore old upstream PR 7481 - rtti_scan: scan the last aligned qword of a section for a COL pointer #648
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/648"
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 ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T10:52:28Z.
Claimed in the coordination issue as: OLD-7481 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129329833
Restoration of my original pull request, old upstream PR 7481 in
ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at21625bca8c; no changes beyond the rebase.What and why
scan_pe64_rttilooks for vtables by scanning each section's aligned qwords for a CompleteObjectLocator pointer.range(start, hi - 8, 8), so the qword athi - 8was never read, even though it is the last one that fits in the section.hi - 7, so every qword that fits whole inside the section is read, and none past its end.tests/test_rtti_scan.pyputs the COL pointer in the last aligned qword of a synthetic.rdata. The vtable is found atVirtualSize0x200, and nothing is found at 0x1FF, where the qword no longer fits.Tested
Linux, Python 3.14.10, CPU only, synthetic PE images built by the tests (no game files).
python -I tests/test_rtti_scan.py:main, 30/30 pass;mainwith only the new test added, 31 run and 1 fails (the new test);python -m compileall -q tools testsandgit diff --check: clean.python -I scripts/check_no_game_data.py tools/rtti_scan.py tests/test_rtti_scan.py: clean.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-24T11:50:49Z.
Reviewed on Windows 11 x64 (
Python 3.14.7, CPU only, synthetic PE images only — no game files) against head commit558b1b4e896a8b301668e1632479bd02ee1e77da.Verdict: Looks good — changing the scan stop bound from
hi - 8tohi - 7fixes the off-by-one qword exclusion at section ends without reading pasthi.Checks run locally
main(21625bca):git merge-tree --write-tree upstream/main HEADexited0;git diff --check upstream/main...HEADclean.python -I tests/test_rtti_scan.py -v: 31 tests, OK (1 skipped) (test_report_keeps_permission_bits,POSIX permission bitson Windows).main(21625bca):test_col_pointer_in_the_last_qword_of_a_section_is_scannedfails onupstream/main:tools/rtti_scan.py([] != [{'rva': 8704, ...}]) and passes on this PR.python -I tests/test_ci_registration.py: 15 tests, OK.python -I tests/test_text_write_line_endings.py: 3 tests, OK.python -I scripts/check_no_game_data.py tools/rtti_scan.py tests/test_rtti_scan.pyandpython -m compileall -q tools tests: exit0.Additional synthetic boundary probes
VirtualSizesweep0x1F8..0x208(COL pointer at0x1F8, executable slot pointer at0x200):0x1F8..0x1FF->[]0x200..0x207->[{'rva': 0x2200, 'class': 'Probe', 'offset_in_object': 0, 'slots': 0}]0x208->[{'rva': 0x2200, 'class': 'Probe', 'offset_in_object': 0, 'slots': 1}]VirtualSize = 1, 7([]),VirtualSize = 8with COL pointer at offset0(slots: 0), andVirtualSize = 0, SizeOfRawData = 0([]) all behave cleanly withoutstruct.erroror negative-range issues.VirtualAddress = 0x2004(COL pointer at RVA0x2008, aligned start(lo + 7) & ~7 = 0x2008):VirtualSize = 0x0B(hi = 0x200F) ->[],VirtualSize = 0x0C(hi = 0x2010) -> foundUnalign(slots: 0).scan_pe64_rtti(COL checkrva + 24 > len(img)and vtable slot loopwhile vt + 8 * (n + 1) <= hi); both already use exact inclusive bounds.AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T03:56:06Z.
Review: APPROVED
Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). The last aligned qword starts at hi - 8, and range(..., hi - 8, 8) stopped before it; hi - 7 includes it without reading past the section.
AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:21:48Z.
Merged:
rtti_scanscans the last aligned qword of a section for a COL pointer.main, and no review point is open.tests/test_rtti_scan.pypasses onmain+ this head (Linux, CPython 3.14).mainb8c44ce8e+558b1b4e8: the semantic suite passes (492 files, 6,315 tests, 0 files failed);test_rtti_scanpass; the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 2 changed files.AI-assisted (Claude Code, Claude Opus 5.5).