libkernel: MSG_DONTWAIT can block on Windows after a readiness check #10943
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 lgqdaxia on 2026-10-25T11:15:02Z.
PS5 console results, November 21, 2026 (firmware 9.20). With plain
MSG_DONTWAIT, eight readers competed for one byte. Across eight rounds per socket type, both TCP loopback and local stream sockets returned eight bytes total and 56EAGAINresults. No reader was still waiting at the 0.5 s check. The separate one-byteMSG_DONTWAIT | MSG_WAITALLcases reached setup and hit the 5 s limit before printing a receive result. An immediate one-byte return for that combination remains unconfirmed on PS5. Console measurements by @noisyweather.Latest tested standalone candidate:
6adaa5acdf, based on main88f99678bf, on the candidate branch. It retains the Windows DONTWAIT/progress fixes and @Queuse's authored Unix SSL follow-up, and adds live native-mode handling with independent read/write regressions.SCM_RIGHTS integration:
f54d693980contains that complete candidate plus #7090 at484bc8c2c3, on the same main base. Testing found and corrected a retained callback regression that changed a passed nonblocking socket's EAGAIN into a wait.Windows full builds and 13 selected CTests pass on both pinned versions. Linux actual-source harness results are 6/6 for the standalone candidate and 13/13 for the combined targeted transport suite, including supplementary TCP/TLS-over-passed-socket checks. Four separate passed-option/peer diagnostic checks still fail and remain explicit limitations of the integration stack. Those October results apply to the named Windows builds and Linux harnesses.
Detailed combined results, negative controls, remaining gaps and local TLS driver. The original report below retains its historical revisions and measurements. The diagnostic stack is not a ready upstream PR.
What happens
On Windows, a guest socket call that asks not to wait can still get stuck in a blocking Winsock receive. The readiness check succeeds, but it does not make the following receive nonblocking.
This is a remaining gap explicitly recorded by merged #8186 and the MSG_DONTWAIT debt entry. #8185's unsupported-flag error was fixed; this report concerns the later blocking transfer. The libSceNet changes in #8653 cover a different socket implementation.
Title, test or build step
Synthetic loopback/API regression:
guest_socket_dontwait. No title or homebrew was run.In the original Windows test, one byte is queued on a connected blocking socket, the peer stays open, and
recv(buffer, 2, MSG_DONTWAIT | MSG_WAITALL)(0xc0) is called. The old Windows runtime waits until the peer closes. The candidate test expects one byte immediately. That expectation is provisional pending an isolated console result.A separate contention case starts eight real
recv(MSG_DONTWAIT)calls for one queued byte. One may take the byte; the other seven should returnEAGAIN. With the old blocking transport, some receivers instead remain pending until peer shutdown. No gate or delay is inserted inside production code.AnyPS5 commit
57f506f8119252b43b851b0de18689bc5015a586, freshly built for this investigation.887d081fe30cab8871b91cc6f6c64b127d99713c, based on that main commit.16ff208dc32cf3927ba1bae492eee363a5ae7ae8. Itslibkernel/Socketsources, libkernel CMake registration andGuestSslTransport.cppare unchanged from the tested base. The build/test results below apply to the stated revisions, not a new full run at16ff208dc3.System
Windows 11 10.0.26200, Intel Core i7-12700H, WinLibs GCC 15.2.0 r7, Release. These socket/SSL tests do not initialize a GPU.
Steps to reproduce
In a separate Windows checkout at main
57f506f8119252b43b851b0de18689bc5015a586, with the toolchain and dependencies from BUILD, take only the test and its registration:Those two restored files add no production fix. The first case reports the failure in about 0.6 seconds, after safely releasing the blocked receiver. It does not depend on a watchdog or CTest timeout to fail.
In another checkout of candidate
887d081fe3, run the same configure, build and CTest commands for the green comparison. The complete regression takes about six seconds here.Log
Main runtime:
Candidate:
The final test EXE was also run with a retained copy of the freshly built main runtime and failed at the same assertion (exit 1, about 0.7 seconds). That is the same EXE used with the candidate runtime. The main libkernel SHA-256 is
65f3bcc96ee93046511bd99c3a2059ac5ebdfa3367590296d1f3cbe5596c3b2b; the candidate is2cc7babed33cf271ae3c4dcb5c7e0c6c8600c635b017ce4a4d64afd7c0e1df86.What was checked
guest_socket_dontwaitregression passed three consecutive runs.libsandrelinkerbuilds, conventions and public-header audit passed. The header audit first hit CTest's 30-second limit; the direct audit passed, then the unchanged CTest passed in 12.59 seconds.Proposed fix and status
The public candidate branch keeps exposed Windows native sockets nonblocking. Guest blocking mode is tracked separately: a normal call waits for the required direction and retries against its deadline; a DONTWAIT call returns the native result immediately. The same path covers the SSL NativeOwner callback so ordinary SSL reads still wait and honor guest timeouts.
The wait uses directional
select. A separate native probe found thatWSAPollcan repeatedly report HUP after a peer half-closes while a full send queue still returns would-block; watching the exception set also wakes on unrelated urgent data. The probe checked that write-only select waits in those cases and still wakes on a reset. The formal test checks the timeout behavior, not CPU usage.The transport changes and regression are in #12688, which lists
Fixes #10943. Its immediate one-byte assertion for the combined flags is subject to the console finding above. Blocking WindowsMSG_PEEK | MSG_WAITALLremains unsupported (EOPNOTSUPP) and is recorded in debt. Single large-send probes did not establish backpressure; the regression instead fills the queue with bounded small sends untilEAGAIN.The original reproduction and logs in this section came from local Windows synthetic tests.
AI-assisted: yes