libkernel: the first stream send after a socketpair peer closed succeeds and a datagram recv reports ECONNRESET on Windows #15661

Closed
opened 2026-11-04 00:50:49 +00:00 by Opensource55 · 0 comments
Opensource55 commented 2026-11-04 00:50:49 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Opensource55 on 2026-11-04T00:50:49Z.


What happens

After the peer of a guest socketpair closes on a Windows host, the first stream send succeeds where the console returns EPIPE (32), and a datagram recv with an empty queue reports ECONNRESET where the console reports ENOTCONN (57); both deviations are documented in the socketpair entry of docs/dev/debt/libkernel.md.

Title, test or build step

guest_socket_pair (ctest #3552) on Windows; no title is known to reach this; the gap is recorded in docs/dev/debt/libkernel.md (socketpair entry)

AnyPS5 commit

main 4f41f4c375

System

Windows 10 Pro for Workstations 22H2 (10.0.19045.6456), MinGW-W64 GCC 15.2.0 (UCRT, Release build), AMD Ryzen 9 5950X; no GPU involved

Host report


Steps to reproduce

On a Windows build of main 4f41f4c375 (host-layer test, no title involved):

  1. Take the fix branch https://github.com/Opensource55/AnyPS5/tree/fix/socketpair-close-semantics - its GuestSocketPair.cpp adds the two cases: close one end of a stream pair, then send once from the other end with the no-signal flag; close one end of a datagram pair, then recv from the other end with nothing queued.
  2. Revert the implementation while keeping the tests: git checkout 4f41f4c375 -- core/libs/prx/libkernel/Socket/src/Udp.cpp && ninja -C build guest_socket_pair_tests
  3. build\tests\guest_socket_pair_tests.exe aborts at the first-send assertion (Require(send_nid_postfix(...) == -1 && *__error_nid_postfix() == 32)), exit via SIGABRT.
  4. Restore the branch's Udp.cpp, rebuild, run: rc 0 on three consecutive runs; ctest -R socket passes 30 of 30 in 6.7 s.

Log

[time] scheduler tick raised to 0.5 ms (was 0.50 ms, now 0.50 ms, timed waits fine)
[src/HostCpu.cpp:220 operator()] host CPU AMD Ryzen 9 5950X 16-Core Processor: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, LZCNT, BMI1, BMI2, MOVBE, CMPXCHG16B, LAHF/SAHF, AVX, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, RDSEED, ADX, SHA, CLFLUSHOPT, CLWB, RDPID, XSAVEOPT, XSAVEC, SSE4A, PREFETCHW, CLZERO, OS AVX state (XCR0); lacks none
FATAL: abort() (SIGABRT) on thread 3532
    #0 0x00007ffa2f0c8a68 libc.prx+0x18a68
  stack return address candidates:
    [rsp+0x8] 0x00007ffa2f0c8c75 libc.prx+0x18c75

What was checked

  • FreeBSD 11.4 sys/kern/uipc_usrreq.c: uipc_detach calls unp_disconnect, whose SOCK_STREAM branch calls soisdisconnected on both ends, so sosend_generic answers EPIPE; the SOCK_DGRAM branch clears only the closing end's state and sets no error on the survivor (unp_drop with ECONNRESET is the uipc_abort path). The console's ENOTCONN for the datagram receive is the behavior documented in docs/dev/debt/libkernel.md, so the receive fix is Windows-gated and the POSIX hosts keep their native answers.
  • Prior work here: #8670 (merged; the sends-after-it half, via #8669), #5510 (closed), open #14043/#8605/#15135/#11896 touch neighboring semantics; none covers the two answers above.
  • Same result on every run: the red side aborts at the first-send assertion, the green side passes three consecutive runs.
  • Fix branch (2 commits, unpushed; the PR will point Fixes: at this issue once it is confirmed): https://github.com/Opensource55/AnyPS5/tree/fix/socketpair-close-semantics
  • AI-assisted (WorkBuddy).
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6193993678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/15661). Originally posted by [Opensource55](https://github.com/Opensource55) on 2026-11-04T00:50:49Z. --- ### What happens After the peer of a guest `socketpair` closes on a Windows host, the first stream `send` succeeds where the console returns `EPIPE` (32), and a datagram `recv` with an empty queue reports `ECONNRESET` where the console reports `ENOTCONN` (57); both deviations are documented in the socketpair entry of `docs/dev/debt/libkernel.md`. ### Title, test or build step guest_socket_pair (ctest #3552) on Windows; no title is known to reach this; the gap is recorded in docs/dev/debt/libkernel.md (socketpair entry) ### AnyPS5 commit main 4f41f4c375 ### System Windows 10 Pro for Workstations 22H2 (10.0.19045.6456), MinGW-W64 GCC 15.2.0 (UCRT, Release build), AMD Ryzen 9 5950X; no GPU involved ### Host report ```text ``` ### Steps to reproduce On a Windows build of main 4f41f4c375 (host-layer test, no title involved): 1. Take the fix branch https://github.com/Opensource55/AnyPS5/tree/fix/socketpair-close-semantics - its `GuestSocketPair.cpp` adds the two cases: close one end of a stream pair, then `send` once from the other end with the no-signal flag; close one end of a datagram pair, then `recv` from the other end with nothing queued. 2. Revert the implementation while keeping the tests: `git checkout 4f41f4c375 -- core/libs/prx/libkernel/Socket/src/Udp.cpp && ninja -C build guest_socket_pair_tests` 3. `build\tests\guest_socket_pair_tests.exe` aborts at the first-send assertion (`Require(send_nid_postfix(...) == -1 && *__error_nid_postfix() == 32)`), exit via SIGABRT. 4. Restore the branch's `Udp.cpp`, rebuild, run: rc 0 on three consecutive runs; `ctest -R socket` passes 30 of 30 in 6.7 s. ### Log ```text [time] scheduler tick raised to 0.5 ms (was 0.50 ms, now 0.50 ms, timed waits fine) [src/HostCpu.cpp:220 operator()] host CPU AMD Ryzen 9 5950X 16-Core Processor: has SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, LZCNT, BMI1, BMI2, MOVBE, CMPXCHG16B, LAHF/SAHF, AVX, AVX2, FMA, F16C, AES, PCLMULQDQ, RDRAND, RDSEED, ADX, SHA, CLFLUSHOPT, CLWB, RDPID, XSAVEOPT, XSAVEC, SSE4A, PREFETCHW, CLZERO, OS AVX state (XCR0); lacks none FATAL: abort() (SIGABRT) on thread 3532 #0 0x00007ffa2f0c8a68 libc.prx+0x18a68 stack return address candidates: [rsp+0x8] 0x00007ffa2f0c8c75 libc.prx+0x18c75 ``` ### What was checked - FreeBSD 11.4 `sys/kern/uipc_usrreq.c`: `uipc_detach` calls `unp_disconnect`, whose `SOCK_STREAM` branch calls `soisdisconnected` on both ends, so `sosend_generic` answers `EPIPE`; the `SOCK_DGRAM` branch clears only the closing end's state and sets no error on the survivor (`unp_drop` with `ECONNRESET` is the `uipc_abort` path). The console's `ENOTCONN` for the datagram receive is the behavior documented in `docs/dev/debt/libkernel.md`, so the receive fix is Windows-gated and the POSIX hosts keep their native answers. - Prior work here: #8670 (merged; the sends-after-it half, via #8669), #5510 (closed), open #14043/#8605/#15135/#11896 touch neighboring semantics; none covers the two answers above. - Same result on every run: the red side aborts at the first-send assertion, the green side passes three consecutive runs. - Fix branch (2 commits, unpushed; the PR will point `Fixes:` at this issue once it is confirmed): https://github.com/Opensource55/AnyPS5/tree/fix/socketpair-close-semantics - AI-assisted (WorkBuddy).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#15661
No description provided.