Remove stale owner entry in xmem::arrange when target slice is unowned #437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/437"
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 TaynanGT/Vice-Tay. Originally posted by ahmetbagci8 on 2026-11-29T11:23:35Z.
Problem
In crates/victory-hle/src/modules/xmem.rs, rrange() builds an owner: HashMap<usize, usize> mapping slice_index -> page_number for the section. When moving *number from slice have to want:
On a subsequent iteration that wants have, owner.get(&have) finds the stale *number and overwrites its slice.index, leaving *number at the wrong slice instead of want.
Fix
Remove have from owner in the else branch when want has no current owner, and add a unit test (rrange_clears_stale_owner_when_target_slice_is_unowned) covering the freed-slice case.
Verification
Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T11:35:21Z.
Thanks for isolating the stale reverse mapping. The freed-slice regression is useful; please also check that the normal occupied-target swap retains both owners and that subsequent rearrangements cannot see the old entry.
Imported from TaynanGT/Vice-Tay. Originally posted by Kal0s-design on 2026-11-29T12:57:58Z.
Review: COMMENTED
Ran this on Windows.
cargo test -p victory-hle --libgives 223 passed (the xmem group is 19), andcargo clippy -p victory-hle --all-targets -D warningsis clean. With theelsebranch taken out, the new test fails on the[Some(1), Some(2)]assertion. With it in, it passes.The fix looks right. Once
numberleaveshavefor an unownedwant, nothing ownshaveany more, so leavingowner[have] = numberlets a later iteration movenumberback. Theelsealso covers the case whereownernames a page that's no longer in the table, which is the right outcome there too.AI-assisted: yes
Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:03:57Z.
Thanks for running this natively and confirming the regression fails without the else branch. The new test exercises two consecutive moves into unowned slices, so the stale reverse entry is covered directly. Please keep the existing occupied-target swap coverage alongside it.
Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:07:07Z.
mainhas moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the currentmainand open a new PR; I'll review it there.Pull request closed