feat(libkernel): implement getdtablesize and fix Windows host-tree removal #7039
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7039"
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 nabil88 on 2026-10-17T07:04:50Z.
What
Make the Windows test suite pass, implement one missing libkernel export, and stop removing host trees with the MinGW
remove_allhang.getdtablesizeis implemented inlibkernel: it returns theRLIMIT_NOFILEsoft limit thatgetrlimitreports, capped atINT_MAX. Theguest_getrlimittest covers it and the debt note is updated.std::filesystem::remove_allin MinGW libstdc++ (GCC 15/16) never terminates on a tree that contains a symlink, because it does not treat a reparse point as a link; the libstdc++ fix is only in GCC 17.core/libs/prx/libc/include/RemoveTree.hppremoves a Windows tree itself (removes a reparse point as the link it is, clears the read-only attribute and retries, reports the first native error) and replacesremove_allinlibSceSaveData.nativedeleteSave,libSceSaveDatamount_internal/delete_internal,libSceAppContentClearDirectoryand theguest_kernel_systemporary tree. Other hosts keepremove_all. TheShaderDiskCacheeviction still usesremove_all; it is left to a follow-up because three open pull requests rewrite that file.Tested
Windows, WinLibs GCC 15.2.0 (the supported toolchain), full
build-fullsuite.guest_getrlimit,guest_kernel_sys(0.27 s),guest_savedata_delete,guest_savedata_searchandguest_appcontentpass; the conventions and registration checks pass 18/18.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)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T07:14:32Z.
Thanks. The force-push to 0a43b89da dropped the AGC alignas commit (GpuIndirectArgumentsMisalignedWriterAhead), but the PR description still mentions it. Could you update the description to match what the PR now contains? Full CI is running on 0a43b89da.
Imported from boykopovar/AnyPS5. Originally posted by nabil88 on 2026-10-17T07:20:34Z.
Updated when the template was filled in - the description no longer mentions the AGC alignas commit. That fix already landed on
main, so it is not part of this PR; the description matches the three commits on 0a43b89da.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T07:30:31Z.
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)docs/dev/debt/libc.mdL88-89core/libs/prx/libSceSaveData/SaveDataCore.hppL1-1326Some 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.
CMakeLists.txtCMakeLists.txtCMakeLists.txtdocs/dev/debt/libc.mdCMakeLists.txtcore/libs/tests/GuestKernelSys.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdCMakeLists.txtCMakeLists.txtcore/libs/prx/libSceSaveData.native/Export.cppCMakeLists.txtCMakeLists.txtcore/libs/prx/libSceSaveData.native/Export.cppdocs/dev/debt/libc.mdCMakeLists.txtCMakeLists.txtdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mdCMakeLists.txtdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T10:02:24Z.
Thanks for the update. The getdtablesize and timeout commits are unchanged from the reviewed head, and the Windows symlink/junction handling in
RemoveTree.hpplooks right. One fix is needed before merge:The one-argument
RemoveTree(path)swallows errors on every host, Linux included (RemoveTree.hpp:55-57passes anignorederror_code). It replaces a throwingstd::filesystem::remove_allinlibSceSaveData.native/Export.cpp(deleteSave, ~:259) and in AppContent'sClearDirectory. So when a save delete fails,sceSaveDataDeletenow returnsSAVE_DATA_OKwith the data still on disk. That means the description's "other hosts keep remove_all" holds only for the call sites that pass an error_code.Fix: make the one-argument overload throw
std::filesystem::filesystem_errorwhen the error is set (the oldremove_allbehaviour), or return the error to the caller the waydelete_internaldoes.Minor (Windows): in the error_code overload, the range-for over
directory_iteratorcan still throw while incrementing. Iterating withincrement(ec)would keep it non-throwing.Also, the commit message for 557e777cb mentions shader disk cache coverage, which the change doesn't include. Please drop that line.
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-17T10:03:42Z.
Windows 11 Pro 26220, Ryzen 7 5700X, MinGW GCC 15.2.0 (WinLibs r7), Developer Mode on, shell not elevated: head
0a43b89damerged on main5f61879a9. The PR has since moved to557e777cb; thegetdtablesizeand timeout commits are the same there, and theremove_allchange moved from the test intoRemoveTree.hpp, which I have not built or run. The hang observations below are about the toolchain, so they should still apply.libs: pass.guest_kernel_sys,--repeat until-fail:3: 3 of 3 pass (1.35, 0.42, 0.39 s);guest_getrlimit: 3 of 3 pass.remove_allhang does not reproduce here. Onmainguest_kernel_syspasses (2 of 2, 0.6 and 1.3 s), and with theremove_allchange reverted (everything else from the PR kept, rebuilt,--timeout 120) it passes 3 of 3 again (1.3 to 1.4 s). In this libstdc++,std::filesystem::create_symlinkreturns "Function not implemented", but the guestsymlinkpath creates real links withALLOW_UNPRIVILEGED_CREATE, so the test does leave file, dangling, directory and absolute links in the tree when it callsremove_all. A separate probe ofremove_allover a tree holding each of those kinds of link (and a two-link loop) also terminates. Two kinds do not hang but return an error and leave the tree behind (a directory link to.:ec=22; a dangling directory link:ec=2);guest_kernel_syscreates neither on Windows. So I cannot confirm the hang on this toolchain, and the negative control shows no difference; if it depends on a specific libstdc++ build or link kind, a note on which would help.ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip': 876 listed, 854 pass, 2 skipped, 20 time out on a host that was heavily loaded by other builds (757 s). All 20 pass on serial reruns; none touches the changed files. With the raised limits,conventions_function_bodies*still timed out at 60 s in five of six shards under that load (14 to 47 s serially);hardware_oracle_comparepassed in 107 s (limit 120 s) andwindows_dependency_diagnosticsin 17 s.hardware_oracle_comparewas below its measured 68 s direct run).tools/check_conventions.py --base origin/mainandgit diff --checkpass on0a43b89da.getdtablesizeis NIDsZuwaDPATKsin aerolib and the export already existed inlibkernel.prx. Local relinked registries: PPSA85300 and PPSA97358 import it; neither calls it on a path that runs, so no title run was done. The new test expects the same formula the implementation uses, so it would not catch a missing host bound.873fbe99a) also implementsgetdtablesize: the same function inProcess.cpp, the same assertion inGuestGetrlimit.cpp, the same line inlibkernel.md. Each merges cleanly into current main alone; together they conflict in those three files in either order. On Windows both return 8192. They differ elsewhere: #6201 bounds the result by the hostgetdtablesize()on non-Windows (the macOS case from its review), this PR returns the guestRLIMIT_NOFILEsoft limit. CONTRIBUTING allows one open PR per function; I take no position on which one should carry it.Not checked:
557e777cbitself (RemoveTree.hpp, the save-data and AppContent call sites), macOS and Linux, GPU tests, any title run, the hang on another toolchain.Written with Claude Code assistance (validation by a subagent, reviewed in this session).
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T10:09:54Z.
Review: COMMENTED
Linux run, since the description lists only Windows.
getdtablesizeand theremove_allfallback ofRemoveTreeare the parts that run on Linux.Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build.Head
3b744c269merged ontomain9caecfd2d(clean merge).guest_getrlimit,guest_kernel_sys, the savedata and appcontent tests andwindows_dependency_diagnosticspass (ctest -R "getrlimit|kernel_sys|savedata|appcontent|dependency_diag|windows_dep", 16 tests).GuestGetrlimit.cpponly, onmain: aborts withgetdtablesize_nid_postfix not implemented, so the updated check exercises the new code.ctest -E "^agc|gpu|vulkan|video_out"): 712/712, same asmain.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T10:21:58Z.
Thanks for the rebase. It's a clean rebase with no code changes, so the two points from our review are still open:
RemoveTree(path)still drops errors silently, on every host including Linux;error_codeoverload can still throw mid-walk, because the range-for overdirectory_iteratoruses the throwingoperator++.Could you push a fix for both? We'll re-review and run CI as soon as it lands.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T22:51:55Z.
A friendly check-in: the two points from our review are still open on 3b744c269b:
RemoveTree(path)still drops errors silently, on every host including Linux;error_codeoverload can still throw mid-walk, because the range-for overdirectory_iteratoruses the throwingoperator++.The branch also conflicts with
mainnow, so it needs a rebase too. Could you push the fix together with the rebase? We'll re-review and run CI as soon as it lands.Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-19T09:05:33Z.
Overlap note: I've opened #7824, which fixes the Windows failures in
GuestKernelSys.cpp(dangling symbolic link removals) and replaces the same finalstd::filesystem::remove_all(root)cleanup this PR handles withRemoveTree. No dependency either way; if this lands first I'll rebase #7824 ontoRemoveTree.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T17:37:39Z.
Rebased onto current
mainand addressed both open review points as our own commit on your branch:getdtablesizecommit: it landed in #6201.RemoveTree(path)(one argument) now throwsstd::filesystem::filesystem_erroron failure on every host, like theremove_allit replaces, sosceSaveDataDeleteno longer reports success when the delete failed.directory_iterator::increment(error_code&), so theerror_codeoverload no longer throws mid-walk.GuestKernelSyscleanup callsRemoveTreeinstead of thecmd /c rdworkaround from #7824.Full ctest passes after the rebase; the Build run covers Windows; merged.