fix: guard runtime method tables past their last slot #257
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!257
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-257"
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?
@Skyfrye on GitHub · 2026-11-25 21:57 UTC · original
Skyfrye:nep/runtime-table-bounds→main· +173 −29 · 14 files · 1 commits · draftDraft: the in-game check on this base is pending (the test machine's GPU is in use for a few hours). Everything else below is done.
Change
The runtime objects VIctory hands to the title (the
QueryApiImplareas and the DirectStorage objects) each point at a fixed-length array holding the methods implemented so far (Methods<N>invictory-hle/src/modules/xgameruntime.rs). Nothing came after the array. A title that calls a method past the last slot we list (a newer runtime interface, or a method we have not met yet) read a function address from whatever memory followed the table and jumped there: a crash far from its cause, with nothing in the log to name the area or the slot.Every table built through
Methods::newnow carries 64 more slots after its known methods. Each is a stub that logsruntime method not implemented (past the end of its table)with the area and the slot offset at WARN, once per area and slot, and returnsE_NOTIMPL. The stub takes onlythis, so any argument list is safe to pass under the x64 convention (the caller cleans up). Existing slots are unchanged, andmissing::<SLOT>keeps answering for the unimplemented slots inside a table.Why 64: the runtime's interfaces are not public, so their real method counts are unknown; 64 slots is 512 bytes of static data per table (26 tables in 14 modules).
Not covered here (other table types, each its own change if wanted): GameInput's
Table<N>, the XGVtable, the media and audio structs, and the D3D tables invictory-gpu.Linked issue: none.
Verification
Windows 11 26300, Rust 1.98.1 (MSVC), builds and tests at below-normal priority, RTX 5080, on upstream
mainataffaf15(the Neptune base, PR #243), fromthird_party/victory.With the 64 slots left null and the tests kept, both
every_*_guardedtests fail (the third test, a call into slot 4, is not run that way: it would jump through null).In game: pending on this base. On the previous base (
4f2cf5c), two runs of 240 s and 300 s to the prologue's first interior (GTA VI 1.0.2.1, my own copy, launcher settings) with this and three other local fixes: no exception, no device loss, and the new WARN line never appeared (the title did not call past a table there).Oracle and test data
None involved. Failure case:
a_call_past_the_end_returns_e_notimpl_and_is_logged_oncecalls slot 4 of a 4-slot table, andevery_area_table_is_guarded_past_its_methods(plus the DirectStorage one) calls all 64 slots past every served table with five arguments. Without the change the tests do not compile (they useMethods::new); what they exercise is, before the change, a jump through unrelated memory, which a test cannot assert safely.Checklist
E_NOTIMPL), never a fake success.AI assistance: written with Claude Code. Claude Opus 5.5 wrote the change and its tests from a review of the HLE modules; Claude Fable 5.2 reviewed the diff and ran it in game on the previous base; Claude Sonnet 5.5 ported it to the Neptune base and ran the checks there; Claude Opus 5.5 reviewed the port, ran the game on my machine and wrote this description.
🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-26 00:06 UTC · original
Reviewed: this looks good to merge (tests pass, only the 3 known victory-gpu failures from main). Please mark it ready for review when you are happy with it and we will merge it.
@KainanP on GitHub · 2026-11-26 10:32 UTC · original
Test report for #257.
Merges cleanly onto current main. Setup: current
origin/main(c4c93bd) merged with this PR, Windows 11 on the RTX 4060 Laptop machine.cargo test --locked -p victory-hle(CPU only, so I did not repeat it per adapter).victory-hleno_dll_plantingNo failure. The three new tests pass.
Notes from reading the diff:
Objectis#[repr(C)]and gets a third field. The DirectStorage instances (File,StatusArray,Queue) start with that header, so their state moves 8 bytes. That is fine while only our code reads past the header. I found nothing that hands a fixed header size to the title.PAST_ENDtable has 160 entries, soN + 64 <= 160caps a table at 96 known methods. Theconstassert catches this at compile time. The message could name the limit ("raise PAST_END rows past 96 methods").past_endderefsthisto getarea. If a title ever calls a stub with an object we did not create (a wrong pointer), this reads through it. That is no worse than before, but the stub could logthisas well.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.