fix(libc): check a whole range before collecting its writes with reset #2328
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2328"
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 TheAggie on 2026-10-09T15:41:13Z.
What
WindowsMappings::Collect(behindGuestArenaCollectWrites_nid_postfix) resets each part of a range as it walks it whenclearis set. It marks a shared view's page seen and re-arms its aliases, and it callsGetWriteWatchwithWRITE_WATCH_FLAG_RESETon private memory. When it then reaches aPAGE_NOACCESSview, or memory that isn't committed private memory, it returnsfalse. By then the parts before that point are already reset.The callers treat
falseas "this range can't be tracked" and fall back, for example to collecting the pieces separately. But the writes to the reset parts are gone, so the fallback no longer sees them.walkWritesdocuments the failure ("Uncommitted pages inside the range make the call fail; such ranges are compared instead") but not the lost writes. Today's callers mostly collect exactly one allocation, which avoids it. I hit it while trying to collect several nearby heap mirrors in one walk: a span with an uncommitted page in the middle lost the writes before the hole.With
clear,Collectnow checks the whole range first, with the same tests the walk uses (noPAGE_NOACCESSview, private memory committed), and returnsfalsebefore resetting anything. A collect withoutclearresets nothing and is unchanged. The walk itself is unchanged.Test (
guest_memory, Windows),CheckFailedCollectKeepsWrites:false, and a collect of the first page alone still reports the written page.Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti (driver 610.88).
guest_sce_nettimed out (it times out locally on unrelated branches too, likely my network filtering), andaudio_out2_timingfailed once in the parallel run but passed 3 of 3 runs alone. It was run from the generatedCTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.tools/check_conventions.py --base origin/mainpasses.The Linux path (
GuestWriteWatch::Collect) isn't touched. Not tested on Linux or macOS.#2054 also changes
Collect's private-memory branch.WindowsMappings.hppmerges cleanly with it; the conflicts are adjacent additions intests/GuestMemory.cppandTechnicalDebt.md. I'll rebase onto whichever lands first.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:53:03Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
bbdb35b1:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).WindowsMappings.hppandGuestMemory.cpp. Prevents partial reset and inconsistent write tracking.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:32:32Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/tests/GuestMemory.cppL1191