xmem: 32-bit XMemFreeDefault frees without telling victory-gpu (title_memory_freed) #216
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 avatarmanz/VIctory-7900XTX. Originally posted by kekonn on 2026-11-26T11:55:32Z.
What goes wrong
crates/victory-hle/src/modules/xmem.rs:369releases 32-bit allocations with the host'sVirtualFree(address, 0, MEM_RELEASE)directly.The allocation itself went through
XMemVirtualAlloc(~327-334), which callsvictory_gpu::title_memory_allocated(~180-182). The title's ownVirtualFreegoes throughtitle_virtual_free(~1986), which callsvictory_gpu::title_memory_freedfirst. 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_allocatedonly clearsheldblocks, soprotected/cleanbits stay set. A copy can then treat fresh, writable memory as clean and skip it.When
The default path, for
XMemFreeDefaultwithALLOC_32BITattributes. This is reached throughXMemFreeonly when the title exports no__XMemAllocationHooks__, or when its hook or middleware callsXMemFreeDefaultdirectly.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_freedfinds the allocation's end itself, a path thewatch.rstests 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