fix(agc): read committed guest pages on Windows without faulting on released pages #10575
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10575"
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 Mouhand-Kaddo on 2026-10-24T10:44:52Z.
What
On Windows, Demon's Souls (PPSA01342) stops with an access violation while it loads the tutorial level, on
mainand with #7844:The title samples a texture at
0x38400of 352 MiB (DCC keys at0xc47000000200) that lies in no registered guest allocation.ReadCommittedandEqualsCommittedfirst find the readable pages of the range, then copy or compare them. On Linux that range is the executable image and stays mapped. On Windows it covers host heap pages that other threads release between the check and the copy, so thememcpyfaults.On Windows these two functions now read through
ReadProcessMemory: the whole range first, then page by page if that fails. A page that cannot be read counts as uncommitted, as it would have a moment earlier: zero in a copy, left out of a comparison. Linux keeps the direct copy. The texture still takes whatever host bytes are readable there, as before; the debt entry records that.This is separate from #7844 (host import budget), but on Windows both are needed to reach the level: #7844 removes the import refusals, and this removes the crash.
Risk: Windows only, two functions.
ReadProcessMemoryon the own process copies in the kernel instead ofmemcpy; a failed whole read falls back to per-page reads. The compare buffer lives inHostThreadLocal, since athread_localdestructor in a PRX runs after emulated TLS has freed the object on Windows.Tested
Windows 11 Pro 26300, i7-13700K, 32 GiB, AMD Radeon RX 6900 XT, driver 32.0.21045.16010, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, onmain887a9640b.RunVanishedPageReadTestsinagc_driver_graphics: an arena page released afterAccessiblecached it as readable. Without the change the test exits with0xc0000005inucrtbase(the same fault as the title); with it, the page reads as zero and is skipped in a comparison. Linux keeps the direct copy, so the test is Windows-only. It requires the guest arena rather than returning when it is missing; undergdba breakpoint on it is hit andagc_driver_graphics_testsends withGraphics validation tests passed.ctest -R agc -j 8: 998 of 1001 pass.agc_driver_sample_order,agc_driver_sample_order_grid_referenceandagc_driver_sample_order_recipe_depth_locationsfail the same way withmain'sGuestMemory.cppon this GPU.agc_driver_image_sint8,agc_driver_image_srgb_load,agc_driver_image_table(texture reads through these functions) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: the layer loads, nowas not foundline, pass, noVUID-onmainor with this change.host_thread_localandprx_thread_local_destructorspass. The destructor check fails on a build with the rawthread_localvector:equalsCommittedBytes registers a thread_local destructor.tools/check_conventions.py --base upstream/mainpasses.--windows --to-intel, 1080p (+r_Wants4K = WantsPerfin a copy of therenderconfig_ps5_*.txtfiles), a new character, main menu → Continue → Continue Offline, warm shader cache,SDL_AUDIODRIVER=dummy:main(default import budget 8127 MiB): the access violation above while loading (1 run; 855,847 imports refused).DemonsSouls.exe+0x84dc42, a pointer holding what look like half-float texels) happens early at start-up onmainand with #7844 alike; this change does not touch it.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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:59:24Z.
Review: APPROVED
Reviewed exact head
4201b8212a0c4d6a0b09b6274467192993c80ebb. The Windows-specific paths useReadProcessMemoryfor the current process and retry page-sized ranges after a partial or failed large read; failed pages are zero-filled for copies and omitted from equality comparisons, which matches the committed-memory behavior described by the tests. The change leaves non-Windows reads unchanged. Diff check is clean, and hosted conventions/labels pass; build and register-context jobs are skipped by the current workflow policy. I reviewed the supplied Windows reproduction and test report but could not run the Windows-specific regression locally.