Repository navigation
Conversation
Guest descriptors are host C runtime descriptors. Closing descriptor 0, 1 or 2 closed the host process's standard stream, and the runtime then gave that number to the next file opened anywhere in the process, including files libkernel opens itself, such as the APR reader's. The title's next close of the same number closed that file mid-read. close and sceKernelClose now fail with EBADF for descriptors 0 to 2 that were open when libkernel loaded, and leave them open. A standard descriptor that was not open at load can still be opened and closed by the guest. PPSA21703 calls sceKernelClose(0) repeatedly while loading asset bundles, which made APR reads return 0 or a part of the requested bytes and raised UCRT invalid parameter reports from close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 9c30f0e)
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Carries the single commit from SynnZer0's intake-closed #3295, preserving the original commit author. The fix records which of descriptors 0–2 were open when libkernel initialized and returns
EBADFfromclose/sceKernelClosefor those descriptors, keeping host standard streams from being closed and reused for guest files. Descriptors that were closed at initialization remain available to guestopenandclosecalls.This addresses #4223's reproduced failure: repeated
sceKernelClose(0)calls can otherwise close stdin, let a later guest file reuse fd 0, and close that file while another thread reads it. The carried change was replayed onto currentmainwithout conflicts. Its changes toOpen.cppandStdio.cppalso merge cleanly with open PR #3840.Tested
maina11c8f7f7plus this fix: 16 runs of 240 seconds across four PSNCore-fix variants, zero crashes; the file test subset includingguest_host_streams, conventions and test registration passed.guest_host_streams, and three 90-second Vampire Survivors runs without the APR/UCRT errors.git diff --checkandtools/check_conventions.py --base upstream/main --head HEADpass. I could not configure the local build becauseffmpeg-core,freetype,glslang,SPIRV-ToolsandLibAtrac9submodules are not initialized in this worktree, so I did not run the local test binary.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (n/a).mdfiles or images added to the repository (attach them to this PR)