fix(libkernel): raise the Windows stdio stream limit to RLIMIT_NOFILE #7813
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7813"
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 whamre on 2026-10-19T08:33:25Z.
Requested by Werner
What
On Windows the C runtime allows 512 stdio streams unless
_setmaxstdioraises it, and nothing in AnyPS5 does. Guestfopen/fdopenstreams are stdio streams (_wfdopenin libcFileAndHeap.cpp), and so is thestd::ifstreamthat APR opens for every read (Apr.cpp). Once about 509 streams are open, every further one fails withEMFILE, so APR reads throwAPR: cannot open <path>, whilegetrlimit(RLIMIT_NOFILE)tells the title 8192. This is the error Soul Hackers 2 (PPSA03743) stops on intermittently in #6602, at different points depending on how many files are open.libkernel now raises the stream limit to 8192 when it loads, the Windows counterpart of the Linux build raising
RLIMIT_NOFILEto its hard limit, and thegetrlimitentry in the libkernel debt file says so.guest_getrlimitopens 1024 guest streams on Windows, andguest_apr_readreads through APR while 600 guest streams are open.Tested
Windows 11 (build 26300), WinLibs GCC 16.2.0 UCRT, full library build on current
main:guest_getrlimit,file_streams,guest_filesystem,guest_posix_filesystem,guest_standard_streams(3),guest_apr_read(host, direct, eof, errors, fault, streams) andguest_ampr(markers, threads, cpp_error) pass. Without theOpenFileLimit.cppchange,guest_getrlimitaborts after 509 streams and the APR case fails withAPR: cannot open ...\apr_read_generated.bin. Not tested with Soul Hackers 2 itself (no copy); Linux and macOS are unchanged.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 github-actions[bot] on 2026-10-19T08:41:33Z.
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/GuestGetrlimit.cppL72docs/dev/debt/libkernel.mdL167docs/dev/debt/libkernel.mdL167-168Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/tests/GuestGetrlimit.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/tests/GuestGetrlimit.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/OpenFileLimit.cppcore/libs/prx/libkernel/CMakeLists.txtdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/OpenFileLimit.cppcore/libs/tests/GuestGetrlimit.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.md