fix(libc): forget a released section's pages even while views remain on Windows #5730
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5730"
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 boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T08:13:02Z.
What
Fixes the intermittent Windows
guest_memoryfailure atGuestMemory.cpp:1449(RequireResidentMapping: a fresh mapping of a new direct allocation came back as a view of the section instead of private memory).WindowsMappingskeys each physical page's state by the section handle value.sceKernelReleaseDirectMemoryfrees the backing before it unmaps the views, so~PhysicalBackingcalledForgetSectionwhile the views were still there, and the slots they used were kept. Once the views were unmapped nothing removed them. When Windows later handed the same handle value to a new direct backing, its pages started with the old state:CheckReleaseDirectMemoryClearsMappingsleaves such a slot at offset 0, and the failure only shows when a later backing happens to get that handle value, which is why it is intermittent.Views now share ownership of their slot,
ForgetSectiondrops every slot of the section at once, and JIT shared memory callsForgetSectionbefore closing its section.Tested
CheckForgottenSectionKeepsNoPagesinwindows_write_watch: forgets a section while it is still mapped twice, then checks a new mapping under that handle value is resident private memory, and that bytes of an unmapped page do not carry over.ctest -R guest_memoryand the libc/libkernel tests pass. Windows CI runs the new check.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)