libkernel: readv and writev on a non-blocking pipe fail with EINVAL and ENOSPC instead of EAGAIN on Windows; fix branch ready #4874
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 DavidSamir on 2026-10-13T01:16:05Z.
On Windows,
readvon an empty pipe thatfcntlhas set non-blocking fails withEINVAL, andwritevon a full one fails withENOSPC.readandwriteon the same pipe fail withEAGAIN, as FreeBSD and the Linux build do for all four. A loop that callsreadvorwritevuntil it getsEAGAINtakes either error for a real failure and gives up on the pipe.Cause.
sceKernelReadandsceKernelWritego throughNativeReadandNativeWrite, which turn the C runtime's result for aPIPE_NOWAITpipe intoEAGAIN(ERROR_NO_DATAon a read;ENOSPCwith no Win32 error on a write to a pipe). The vector calls go throughNativeTransferinStdio.cpp, which calls_readand_writewithout it.guest_file_vectoralready checksEAGAINfromreadvon a non-blocking pipe, but only on Linux (#ifndef _WIN32).Observed on
main0428328b7, Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release, on a pipe frompipe()with both ends set non-blocking throughfcntl(F_SETFL, O_NONBLOCK):sceKernelRead, empty pipe0x80020023(EAGAIN)0x80020023sceKernelReadv, empty pipe0x80020016(EINVAL)0x80020023readv, empty pipesceKernelWrite, full pipe0x800200230x80020023sceKernelWritev, full pipe0x8002001C(ENOSPC)0x80020023writev, full pipeI have not found a title that stops on this. I found it while testing #4858.
Fix, ready to cherry-pick.
DavidSamir:fix/libkernel-readv-writev-eagain-windows(f08a58432, one commit onmain0428328b7, two files, +17/-4). I can't open it as a PR while #4532 is open (one open PR without a merged one).Windows only.
NativeTransfergets the two translationsNativeReadandNativeWritehave, with the same conditions. Nothing is called again: it is the error number of the one_reador_writethat is translated. Blocking pipes, files and sockets never produce those two results, so they are not affected.This does not depend on #4858 and does not touch the lines it changes; the two can land in either order.
guest_file_vector: the non-blocking check now runs on Windows too, with the pipe set non-blocking through the guest'sfcntlon both hosts, and is extended to the write side.sceKernelWritevof 16 bytes is repeated until it stops; the nextsceKernelWritevmust return0x80020023andwritev-1 with errno 35, and a read must then succeed.Checked on Windows (f08a58432 on
main0428328b7, Windows 11 10.0.26300, WinLibs GCC 15.2.0 r7, Release, full builds):Stdio.cppas onmainand the test kept,guest_file_vectorfails at thereadvcheck (File vector check failed at line 213). With the fix it passes 5/5 (--repeat until-fail:5), andguest_filesystem,guest_poll,guest_dup,guest_standard_streams,file_streams,guest_aioandguest_kernel_fcntlpass 3/3.main's libraries and the branch's: six lines change, the threereadvcalls on an empty pipe, the twowritevcalls on a full one andreadvafter the pipe has been drained, each to theEAGAINresult the Linux build gives.readandwrite, a zero-bytewritevon a full pipe, the reads and writes that have data or room, the pipe switched back to blocking and the pipe whose write end is closed are identical in both. Against the Linux build the branch still differs wherereadvfills only its first buffer, which is #4858.readvon blocking pipes, files and/dev/urandom, one of 188 lines over the file, directory, vector and mapping functions and one of 122 lines over the descriptor functions, run with both sets of libraries: one line differs in the first (readvon the empty non-blocking pipe), none in the other two.readvon a file 4.1 to 4.4 µs with both sets of libraries; write three bytes to a pipe andreadvthem 1.15 to 1.26 µs with both; write ten bytes and read them back 2.83 to 3.13 µs with both.pollin both (#3644). I do not know whether any of them uses the vector calls on a non-blocking pipe.ctest --parallel 4: 1001 of 1001 pass (7 skipped, no display).tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchreports no overlap with open pull requests, andgit merge-treeof this branch with #4858's merges without conflict.Checked on Linux (same commit, WSL2 Ubuntu 24.04, GCC 13.3.0, Release):
guest_file_vectorpasses 3/3, so the extended check matches the existing Linux behaviour. Only that target andlibswere built there.Not checked on a console or with a commercial title.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:53:48Z.
Closing: no title is known to reach this, and functions are only changed when a title needs them. The catalog titles in the report run the same with and without the change. If a title stops on or misbehaves because of it on current main, comment here with the title ID and the log line.