xmem: 32-bit XMemFreeDefault frees without telling victory-gpu (title_memory_freed) #216

Open
opened 2026-11-26 11:59:04 +00:00 by github-bot · 0 comments
Owner

@⁠kekonn on GitHub · 2026-11-26 11:55 UTC · original

What goes wrong

crates/victory-hle/src/modules/xmem.rs:369 releases 32-bit allocations with the host's VirtualFree(address, 0, MEM_RELEASE) directly.

The allocation itself went through XMemVirtualAlloc (~327-334), which calls victory_gpu::title_memory_allocated (~180-182). The title's own VirtualFree goes through title_virtual_free (~1986), which calls victory_gpu::title_memory_freed first. Its doc (watch.rs ~2656) says that without that call, guarded/clean/absent state noted for the range "would be taken for true of the next memory at the address". When the address is used again, title_memory_allocated only clears held blocks, so protected/clean bits stay set. A copy can then treat fresh, writable memory as clean and skip it.

When

The default path, for XMemFreeDefault with ALLOC_32BIT attributes. This is reached through XMemFree only when the title exports no __XMemAllocationHooks__, or when its hook or middleware calls XMemFreeDefault directly.

Proposed fix (1 line)

Replace the call with the module's own title_virtual_free(address, 0, MEM_RELEASE). With a length of 0, title_memory_freed finds the allocation's end itself, a path the watch.rs tests already cover.

Upstream: no open PR changes this. #142 lists xmem.rs, but its copy is identical to main's.
Status: a fix is being prepared in kekonn/VIctory-7900XTX on branch claude/gifted-clarke-uxuqw8.


Generated by Claude Code

**@⁠kekonn** on GitHub · 2026-11-26 11:55 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/216) ### What goes wrong `crates/victory-hle/src/modules/xmem.rs:369` releases 32-bit allocations with the host's `VirtualFree(address, 0, MEM_RELEASE)` directly. The allocation itself went through `XMemVirtualAlloc` (~327-334), which calls `victory_gpu::title_memory_allocated` (~180-182). The title's own `VirtualFree` goes through `title_virtual_free` (~1986), which calls `victory_gpu::title_memory_freed` first. Its doc (`watch.rs` ~2656) says that without that call, guarded/clean/absent state noted for the range "would be taken for true of the next memory at the address". When the address is used again, `title_memory_allocated` only clears `held` blocks, so `protected`/`clean` bits stay set. A copy can then treat fresh, writable memory as clean and skip it. ### When The default path, for `XMemFreeDefault` with `ALLOC_32BIT` attributes. This is reached through `XMemFree` only when the title exports no `__XMemAllocationHooks__`, or when its hook or middleware calls `XMemFreeDefault` directly. ### Proposed fix (1 line) Replace the call with the module's own `title_virtual_free(address, 0, MEM_RELEASE)`. With a length of 0, `title_memory_freed` finds the allocation's end itself, a path the `watch.rs` tests already cover. **Upstream:** no open PR changes this. #142 lists `xmem.rs`, but its copy is identical to main's. **Status:** a fix is being prepared in kekonn/VIctory-7900XTX on branch `claude/gifted-clarke-uxuqw8`. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:59:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/avatarmanz--VIctory-7900XTX#216
No description provided.