test(libc): protect a resident run region by region in the Windows write watch test #28027
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28027"
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 Plyxen on 2026-11-28T05:01:28Z.
What
windows_write_watchfails on Windowsmain(a163d4b886) in about one run in nine:CheckResidentRunNoAccessTransitions(bc6c3abd98, 2026-11-26) reserves 256 KiB withMappings::Reserve(nullptr, Large), maps it as a resident run withPAGE_NOACCESS, and later restores it with oneVirtualProtect(first, Large, PAGE_READWRITE, ...).WindowsMappings::Mapcommits a resident run in pieces that end at 2 MiB chunk boundaries (chunkBytes), and each piece is its own allocation. When the reservation straddles a 2 MiB boundary, which happens in 3 of the 32 possible 64 KiB-aligned starts, the range is two allocations.VirtualProtectcannot span two allocations and fails withERROR_INVALID_ADDRESS(487).I logged
VirtualQueryat the failure. Every failing run showed two committedPAGE_NOACCESSprivate regions, split 64 KiB + 192 KiB, 128 KiB + 128 KiB or 192 KiB + 64 KiB.The case now restores the range region by region (
ProtectEachRegion), asmprotectinDirectMemory.cppdoes. The otherVirtualProtectcalls in the case cover one 16 KiB page, and a 2 MiB boundary never splits one. The library is unchanged.The case landed after the last Windows Build run that finished (
ab6fe4a981), so CI has not run it yet.Tested
Windows 11, WinLibs GCC 15.2, Release, on
maina163d4b886. I ranwindows_write_watch300 times onmainand 300 times with this change:main: 35 of 300 runs failed (11.7%, close to the 3/32 above), each withcannot restore full resident run protection.The full CPU suite (5,120 tests), with this change applied to
maina163d4b886in a batch with other reviews, has no failure from this change. The three that failed areframe_capture_minimize(a load timeout that also fails onmain),guest_np_common_runtime(from another PR in the batch) andguest_webrtc_null_socket_server, a load flake that passes 30/30 when rerun.The branch is rebased onto
main4c7578e0a4. None of the 30 commits in between touch this file.python3 tools/pr_overlap.py --names CheckResidentRunNoAccessTransitionsreports no matching export changes, because the function is a test case, not an export.python3 tools/pr_overlap.py --branch test/libc-windows-resident-run-protect-per-allocationfailed closed. Two open PRs that changeWindowsWriteWatch.cppconflict withmain, so I compared them by hand:CheckArmedResidentRun.Neither changes
CheckResidentRunNoAccessTransitions. The only shared spot is the include block at the top of the file.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)🤖 Generated with Claude Code
Summary by CodeRabbit
Pull request closed