fix: repair CI failures and collateral bugs from PR #2478 #2649
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2649"
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 sridhar777911 on 2026-10-10T09:58:37Z.
What
This PR fixes the failing CI pipeline checks originally present in PR #2478. During the workflow, additional missing code and collateral issues were found and fixed.
Tested
check_conventions.pyctestsuiteChecklist
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 github-actions[bot] on 2026-10-10T10:01:44Z.
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)dup2_nid_postfixdup_nid_postfixcore/libs/tests/GuestDup.cppImported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:19:19Z.
Additional platform validation on standalone PR head
99763250a9dc15461ebf6218dafda7d0601381a9:Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja.
Release /
BUILD_TESTING=ON: built the selected test targets; 4 CTest cases, 0 failures, 0 CTest skips.Tests:
guest_filesystem,guest_udp,guest_dup,guest_file_vector.Reproduce after building the test targets:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_(dup|filesystem|udp|socket|file_vector|stdio|fd_ownership|file_descriptor)$".Imported from boykopovar/AnyPS5. Originally posted by sandexzx on 2026-10-10T11:38:57Z.
dup/dup2do not keep the random-device bookkeeping consistentI reviewed the code in this PR (it is the same code as #2478; only the merge with
mainis new). I found one real defect that is not documented anywhere, plus one Windows-only defect.The kernel keeps per-descriptor tables for the host resources it emulates:
g_descriptorsincore/libs/prx/libkernel/File/src/RandomDevice.cpp:20andg_locksincore/libs/prx/libkernel/File/src/FileLock.cpp.close_nid_postfix(core/libs/prx/libkernel/File/src/Stdio.cpp:288-298) removes the entry from each table.dup_nid_postfixanddup2_nid_postfixdo not. The new descriptor then has the wrong entry, so it reads the wrong data or takes a lock that does not exist.1.
dup2onto a random descriptor keeps the stale registration —core/libs/prx/libkernel/File/src/Stdio.cpp:319-341dup2_nid_postfixmakestorefer to the object offrom. The host call closes the oldto. Butg_descriptorsstill holdsto(RandomDevice.cpp:42-44). A later read oftogoes throughReadRandomDevice(RandomDevice.cpp:47-49) and returns random bytes, not the data thatdup2moved there. This is silent data corruption.Reproduce:
The mirror case is also wrong: when
fromis a random descriptor, the target never entersg_descriptors, so it reads from the host null device.2. Windows: the file-lock cache is not updated —
core/libs/prx/libkernel/File/src/Stdio.cpp:330-336The Windows branch calls
File::ForgetDirectoryDescriptor(to), but notFile::ForgetFileLock(to). The oldtostays ing_locks. A laterflockon the replaced descriptor then hitsHeldLock(fd) == mode(FileLock.cpp:53-54) and returns success without callingLockFileEx. The caller believes it holds a lock that does not exist.3.
dupof a random descriptor reads as EOF —Stdio.cpp:304-317This is already listed in
docs/dev/TechnicalDebt.md("aduped descriptor reads as an empty file"). It is an accepted limitation, not a new bug. I list it only because a fix for point 1 must also handle the source side.Suggested direction
dup/dup2, read the resource state offrombefore the host call, and change the tables only after the host call succeeds.close_nid_postfix(Stdio.cpp:288-298) is the model: one cleanup point per descriptor.File::ForgetFileLock(to)next to the existingFile::ForgetDirectoryDescriptor(to).dup2(fd, fd)and a faileddup2must leave the tables unchanged.core/libs/tests/GuestDup.cpp. The current tests cover pipes, plain files and sockets, but not/dev/urandom.Related question
GuestSockets::DuplicateTo(core/libs/prx/libkernel/Socket/src/Udp.cpp:237-250) setsnextDescriptor = target + 1whentarget >= nextDescriptor(Udp.cpp:245). Withtarget = INT_MAX - 1the counter reachesINT_MAX, and every laterdup/socket/socketpair/acceptfails withEMFILEfor the rest of the process (Udp.cpp:227,422,501). Is that range reachable in practice, or should the counter wrap?Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T18:08:22Z.
Closing: this is the same dup/dup2 change as #2478, which is green and already fixes the random-device and file-lock bookkeeping still missing here. Anything else you found belongs on #2478.
Pull request closed