Repository navigation
fix(libkernel): read and write guest sockets - #1727
Conversation
|
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.
|
|
Windows run, since the description lists Linux only: Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7, the CI build), Release, configured like CI, Ryzen 9 5900X. This commit merged onto
One Windows difference the test doesn't cover, since the peer-closed AI-assisted: yes (Claude Code). |
833d10c to
62aa3af
Compare
read, write, _read and _write on a guest socket descriptor went to the host, which has no such descriptor, so sceKernelRead and sceKernelWrite threw. They now reach the socket as recv and send without flags, with the socket layer's errno (EAGAIN 35, EPIPE 32, EBADF 9), a zero-length read returns 0 as dofileread does, and the two sceKernel forms return the kernel error for the same cases. The host's SIGPIPE on EPIPE, a write above INT_MAX bytes, readv, writev and the positioned forms are recorded in TechnicalDebt. OpenSSL's QUIC notifier signals its socketpair with write and read. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
62aa3af to
9d0b105
Compare
…t-read-write fix(libkernel): read and write guest sockets
What
read,write,_readand_writeon a guest socket descriptor (0x10000000 and up) went to the host as if the number were a host descriptor, sosceKernelReadandsceKernelWritethrew (sceKernelWrite: write failed, fd=…, errno=9) on the first byte a title moved through a socket that way. On the console both are the socket'srecvandsendwithout flags (soo_read/soo_write).GuestSockets::ReadandGuestSockets::Writein the socket runtime forward torecvandsendwith flags 0, so the socket layer's errno applies:EAGAIN(35) on an empty non-blocking socket,EPIPE(32) after the peer closed,EBADF(9) on a closed descriptor. A zero-lengthreadreturns 0 without touching the socket, asdofilereaddoes, and a read longer thanINT_MAXis clamped.read,write,_readand_writeroute descriptors at or aboveGuestSockets::FirstDescriptorto them;sceKernelReadandsceKernelWritedo the same, before their null-buffer check, and return the kernel error (0x80020023forEAGAIN,0x80020009forEBADF) instead of throwing.EPIPEraises the host'sSIGPIPEon Linux, which the guest can neither ignore nor suppress, and nothing on Windows (the console raises it unlessSO_NOSIGPIPE); awriteaboveINT_MAXbytes isEMSGSIZE;readv,writev,pread,pwrite, theirsceKernelforms and AIO on a guest socket still go to the host.The 15 catalog titles whose OpenSSL QUIC notifier creates a
socketpair(#1711, open) signal it withwriteand drain it withread(rio_notifier.cthroughwritesocket/readsocket); the same applies to any TCP socket a title reads withread.Overlap: #1307 rewrites the four wrappers in
Stdio.cpp(the socket branch has to stay first); #1711 and #1708 insert a TechnicalDebt line at the same place; #1091 and #1738 add declarations toSocketRuntime.hpp, and #1091 code toUdp.cppnear the table, where this adds two declarations and two functions at the end. Whichever merges second rebases. The pr-overlap report's__error_nid_postfixrows (#1613, #1616, #1627, #1675) are the sharedextern "C"declaration of the errno accessor thatOpen.cppnow adds, not an export.Tested
BUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ONon this branch (based onmainb83e849):ctest --repeat until-fail:3467/467;tools/check_test_registration.pyandtools/check_conventions.py --base upstream/mainpass.guest_socket_read_writetest over a TCP loopback pair:write/read,_write/_readandsceKernelWrite/sceKernelReadcarrying data both ways;EAGAINand0x80020023on an empty non-blocking socket; zero-length reads returning 0; 0 from both forms after the peer closed; (Linux)EPIPEonwriteafter the peer closed, with the host'sSIGPIPEignored by the test since a title cannot;EBADFand0x80020009from every entry point on a closed descriptor. Each receive waits withpollfirst, acceptingPOLLHUPafter the close. Written before the change: onmainit aborts with thesceKernelWritethrow above; it passes with the change.main6b56175), run 37822108157:guest_socket_read_writepasses its three repeats, full suite 474/474; the test excludes only theEPIPEcase there, likeguest_tcp.maindb06355 (head 9d0b105;git range-diffshows only context lines changed). Local full ctest: 541/542; the failure,agc_driver_dcc_keys_first_write, fails onmaintoo ([bug] agc_driver_dcc_keys_first_write fails on main on a real NVIDIA GPU #2188). The fork's Build workflow on this head merged intomain8b393b6, run 37996682292: the relinker jobs pass andguest_socket_read_writepasses on Linux; Linux fails onlyguest_video_out_resolution_status(amaintest that aborts on the runner's offscreen SDL driver), and Windows stops buildinglibSceVideoOut.prxon the duplicate export from Windows build fails onmain:duplicate patched export name: LibwuIonIBwin libSceVideoOut (since #1339) #2462, both also onmain.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)🤖 Generated with Claude Code