fix(xgameruntime): make the XMem and XThread edge cases deterministic #43
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Freminet--ScarlettX!43
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-43"
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?
@wildheathen on GitHub · 2026-11-21 19:28 UTC · original
wildheathen:fix/xmem-edge-cases→main· +102 −18 · 2 files · 1 commits · openSummary
Makes a few
XMem/XThreadedge cases deterministic instead of depending on the host allocator. Titles that follow the API do not notice; the HLE now answers the same way everywhere.XMemFree(nullptr)is a no-op and no longer reaches the allocation hook.XMemVirtualAllocwithsize == 0returnsnullptr(on non-Windows hosts it used to allocate 4096 bytes).XMemVirtualFreerejects a decommit without a range (MEM_DECOMMITneeds a size).XThreadAssertNotTimeSensitivelogs the misuse to stderr when called on a time-sensitive thread (the console would break into the debugger; the HLE stays non-fatal).No new functions and no new types.
Tests
tests/test_xgameruntime_abi.cppextends the existing XMem/XThread sections: zero-filled and 16-byte aligned default allocations, a half hook pair is rejected and leaves the current pair alone, freeing null never reaches the hook, zero-size virtual allocation, reserve / decommit / release, and the time-sensitive flag being per thread (a worker starts clean and does not leak its setting back).Verification
origin/main(test_boot_hello_scarlett,test_boot_rt_showcase,test_d3d12_guest_texture; see #1 and #2).XMemVirtualProtect/XMemVirtualQueryright afterXMemVirtualFreeand extends the same test block, so a trivial rebase may be needed depending on merge order.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.