fix(libkernel): share the directory state between duplicated descriptors on Windows #3872
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3872"
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 LeandroLP23 on 2026-10-11T18:20:52Z.
What
On Windows,
dupanddup2of a directory descriptor threw (duplicating a directory descriptor is not supported on Windows). In FreeBSD'skern_dup, both descriptors refer to one open file, so they share the read position. With this change, the duplicate points at the sameDirectoryStatethatgetdentsandlseekgo through, and keeps it after the original is closed.dup2onto an open descriptor first drops whatever the target was, as before. The TechnicalDebtdup and dup2entry no longer lists the case.This builds on #3452 (merged): it uses the shared
DirectoryStatethat #3452 introduced, and its test extendsguest_directory_rewind.Tested
Radeon 860M, Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, on #3452's head
ce0239c94:guest_directory_rewindpasses 3/3. The new checks are:dupshares the cursor, in both directions;lseekon one descriptor moves the other;dup2onto an open file descriptor works, and the result still reads after the source is closed.Stdio.cpp, the test fails with thedup_nid_postfixthrow.guest_file and kernel tests pass, exceptguest_filesystemandguest_kernel_sys, which fail the same way onmain(#3518, #3510).tools/check_conventions.pypasses.Fork CI: https://github.com/LeandroLP23/AnyPS5/actions/runs/38161248929
guest_directory_rewindpasses. The other failures also happen onmain:guest_filesystem,guest_kernel_sysandwindows_exceptions.main'sagc_driver_emulated_color_compare,agc_driver_image_plane_address_on_line_implicit_lodandguest_kernel_stack_protectfail, plus a timeout inagc_driver_flat_apertures_0on lavapipe. The change is all inside#ifdef _WIN32, so none of it is built on Linux.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T13:43:14Z.
Windows test of head
ee8ff43cbmerged onto currentmain(c6efe068a, clean merge; built together with three other open PRs from the same list, so the numbers below are for the combination): Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build 0 errors.guest_directory_rewind(the test this PR changes) passes, withguest_directory,guest_directory_buffer,guest_directory_close,guest_dupandguest_file_*(20 of 20 in the filteraudio_out|guest_directory|guest_dup|guest_kernel_sys|guest_sce_net|guest_file).Not checked: that the test fails without the change, Linux, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T19:05:58Z.
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/prx/libkernel/File/src/Stdio.cppL551-552docs/dev/debt/libkernel.mdL126docs/dev/debt/libkernel.mdL124-126Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T19:35:56Z.
On the overlap comment: none of these depend on this PR or the other way round, and each conflict is resolved by keeping both changes.
_dup(d)indup_nid_postfix, the same spot where this PR adds the directory one. Both lines stay.dup and dup2debt entry; this PR drops the last one ("and on Windows duplicating a directory descriptor"). The merged entry keeps #4391's wording without that clause.cpuset_*entries just above that entry, so the conflict is only the neighbouring lines.Whichever merges first, I'll rebase this one if it's still open.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:17:57Z.
Re-checked after the rebase onto
main(#3452 is in):dup/dup2share theDirectoryStatethrough the existingshared_ptrmap,dup2drops the target's state before duplicating, the original can close without invalidating the duplicate, and the TechnicalDebt entry is updated. Local Linux build and ctest are green; the change is all_WIN32, so the Windows runs reported here (yours and @xXPBSXx's) are what cover the test. Merging.