platform: retry Windows file reads that fail on protected guest pages #1470
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1470
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1470/head"
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?
@Stepz97 on GitHub · 2026-10-13 00:24 UTC · original
Stepz97:fix/windows-file-read-retry→main· +40 −2 · 1 files · 1 commits · closed without mergingSummary
ReadFiledoes not raise a structured exception when its destination buffer falls on a page that the emulator has write-protected for GPU tracking (PageManager). Instead it returns 0 bytes read withERROR_NOACCESS(998) orERROR_INVALID_USER_BUFFER(1784), andSysFileReadtreated that as a successful empty read.Astro Bot (PPSA21564) triggers this during level loading: an effect definition file (
.odxb) comes back empty and the game asserts inRoom.cpp:787("ODX Definition is not found"). Other crashes in loading threads happen in the same phase.Fix
On
ERROR_NOACCESSorERROR_INVALID_USER_BUFFER, restore the file position and re-read through athread_localintermediate buffer (1 MiB). The data is then copied to the guest in user mode, where a write to a protected page faults into the emulator's handler normally. This is the same mechanismlibAmpralready uses for its reads.Test
Windows 10, i7-13700KF, RTX 4080, NVIDIA 617.42,
--amd-cpu --redzone, Astro Bot PPSA21564 01.007.A minimal standalone program confirmed the mechanism:
ReadFileinto aPAGE_READONLYorPAGE_NOACCESSpage returnsFALSEwithERROR_NOACCESS, raises no exception, and leaves the file position unchanged.Related
@Stepz97 on GitHub · 2026-10-13 00:31 UTC · original · edited 2026-10-13 00:32 UTC
Tested with Astro Bot (PPSA21564, 01.007) on Windows 10 (AtlasOS), i7-13700KF, RTX 4080 16 GB, NVIDIA 617.42. Flags:
--amd-cpu --redzone.Without this fix, entering the first level crashes or stalls about half the time — the game reads an effect definition file (
.odxb) that comes back empty becauseReadFilesilently fails on GPU-tracked pages. With the fix, every boot enters the level cleanly: 12 out of 12, with 16 reads recovered through the intermediate buffer and zero short reads.Save select screen
Asteroid field (intro)
Intro sequence
Bots scene (ray tracing active, 12 BVH compute shaders running)
Close-up (52 fps with ray tracing)
@coderabbitai[bot] on GitHub · 2026-10-13 00:38 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
23e14273-8175-4df5-bfb2-3d51b12f9bb9📥 Commits
Reviewing files that changed from the base of the PR and between
df5b9b92beand987d6dbbd4.📒 Files selected for processing (1)
src/common/platform/sysWindowsFileIO.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Walkthrough
Windows file reads now retry through a thread-local buffer if a direct
ReadFilecall fails withERROR_NOACCESSorERROR_INVALID_USER_BUFFER, and the starting file position was captured and restored. The fallback reads chunks of up to 1 MiB and stops on read failure or a short read.SysFileReadreports the resulting byte count throughbytes_read.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
987d6No actionable issue remains from the reviewed Windows read fallback; it is mergeable after normal checks.
Pre-merge checks ·
4 ·
1
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ew-sudo on GitHub · 2026-10-13 19:43 UTC · original
Hi! This looks very close to #838 (opened Sep 25), which fixes the same issue (#745, Astro Bot) with the same approach (seek back + 1 MiB thread-local bounce buffer on ERROR_NOACCESS / ERROR_INVALID_USER_BUFFER). Maybe the maintainers could look at both together and keep one, so the work isn't duplicated?
@Stepz97 on GitHub · 2026-10-13 20:56 UTC · original
@ew-sudo Make sense, I will check, thanks for the heads up.
@Nmzik on GitHub · 2026-10-21 19:42 UTC · original
Duplicate of #838.
Pull request closed