Skip to content

fix(libkernel): return EISCONN from sendto with an address on a connected datagram socket - #7475

Closed
Bonjourcestmatt wants to merge 2 commits into
boykopovar:mainfrom
Bonjourcestmatt:fix/udp-sendto-eisconn
Closed

Bonjourcestmatt wants to merge 2 commits into
boykopovar:mainfrom
Bonjourcestmatt:fix/udp-sendto-eisconn

Conversation

@Bonjourcestmatt

@Bonjourcestmatt Bonjourcestmatt commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

sendto (and sendmsg with a name) with a destination address on an already connected datagram socket now fails with EISCONN (56). FreeBSD 11.4 udp_output() does if (inp->inp_faddr.s_addr != INADDR_ANY) { error = EISCONN; goto release; } when a destination is supplied (read in sys/netinet/udp_usrreq.c, release/11.4.0). Linux and Winsock accept such a send, so the guest socket now checks getpeername first. GuestUdp.cpp pinned the old behaviour in two places (sendto and sendmsg with an address on the connected sender); they now send without an address, and a new check pins the EISCONN result.

Overlap: open PRs #7201 and #7332 (macOS port) touch the same file and #7332 adds a similar EISCONN test expectation, because macOS already returns EISCONN natively; this change is the Linux/Windows side and does not conflict with the macOS host path, though the test lines may need a trivial merge.

Tested

  • Windows 11, WinLibs GCC 15.2.0 UCRT, Release: guest_udp_tests and all 27 udp/socket ctest tests pass; the full non-GPU suite passes (755 of 755, skipped ones included); python tools/check_conventions.py --base origin/main passes.
  • I did not run the new check against main without the fix; it follows from the host accepting the send. The two old sendto/sendmsg lines in the test did fail with the fix, which shows the new check is active.
  • Not run: Linux and macOS, no console. Only the FreeBSD source was used as reference.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted: yes

🤖 Generated with Claude Code

…cted datagram socket

FreeBSD 11.4 udp_output fails with EISCONN when a destination is supplied and
inp_faddr is already set. The host accepts the send, so the guest socket now
checks getpeername first. The test pinned the old behaviour and now sends
without an address on the connected socket.

Written with AI assistance (Claude).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7090 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7201 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8448 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8463 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 8605 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9509 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9515 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9578 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9713 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 9948 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10544 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10621 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 10767 core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestUdp.cpp
PR 10949 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11135 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11141 core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestUdp.cpp
PR 11219 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11223 core/libs/prx/libkernel/Socket/src/Udp.cpp
core/libs/tests/GuestUdp.cpp
PR 11247 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11251 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 11281 core/libs/prx/libkernel/Socket/src/Udp.cpp

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux run, and the check against main that the description leaves open.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON, full build.
Head 90c26b2e3 merged onto main 9caecfd2d (clean merge).

  • guest_udp passes, as do the other socket/network tests (ctest -R "udp|socket|^guest_sce_net$", 16 tests). On Linux getpeername() succeeds on the connected datagram socket, so sendto with an address returns -1 with errno 56, and send / sendmsg without one still deliver.
  • GuestUdp.cpp only, on main: guest_udp aborts at the new sendto(...) == -1 && errno == 56 line (I numbered the Require calls to find it), since the host accepts the send. So the new check fails without the fix.
  • Non-GPU suite (ctest -E "^agc|gpu|vulkan|video_out"): 712/712, same as main.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@ycarogabriel-lgtm

Copy link
Copy Markdown
Contributor

Ran this on macOS, since it was not run there: Apple M1, macOS 26.6.2 (25G83), x86-64 build under Rosetta 2, AppleClang 21. Merged into the macOS host branch of #7332 (57bccfbfc, main at d71853cf2) together with #7121, #7475, #7490, #7507 and #7612; Release build.

AI-assisted: yes (Claude Code). I ran the build and tests on my machine.

@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main is clean. I built only guest_udp_tests; ctest -N -R guest_udp lists exactly one test.

Results (3 runs each):

  • PR head: guest_udp passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libkernel/Socket/src/Udp.cpp with the version from the PR's merge base (e5c2b3c325), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's file afterwards.

Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

adriadam10 pushed a commit that referenced this pull request Oct 21, 2026
The guest socket layer relies on a few Linux calls:

- The equeue wait uses poll with the timeout rounded up to a millisecond;
  macOS has no ppoll.
- A readable stream socket whose peer closed is reported with POLLHUP by
  peeking one byte; macOS has no POLLRDHUP.
- FIONREAD on a datagram socket, and the byte count that fstat and kevent
  report for it, is SO_NREAD, the size of the next datagram; macOS adds the
  source address to FIONREAD.
- socketpair throws for SOCK_SEQPACKET, which has no AF_UNIX pair on macOS.
- gethostbyname replaces gethostbyname_r, which macOS lacks.

The UDP test sends on its connected socket without an address, as #7475
does, because macOS, like FreeBSD, fails sendto with an address on a
connected socket with EISCONN. The log test uses a datagram pair with
enlarged buffers instead of SOCK_SEQPACKET.
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@Bonjourcestmatt

Copy link
Copy Markdown
Contributor Author

Merged origin/main into the branch to resolve a conflict in Udp.cpp with the new zero-port send path: the EISCONN check on a connected UDP socket runs first, then ZeroPortSend. Rebuilt guest_udp_tests on Windows (GCC 15.2 UCRT) and guest_udp passes; Linux/macOS did not run here.

🤖 Addressed by Claude Code

@Bonjourcestmatt

Copy link
Copy Markdown
Contributor Author

Closing: this branch conflicts with the current main (the socket paths were reworked and are now console-measured), and it is a low-value argument-validation change. Thanks to everyone who ran it on macOS and Windows.

🤖 Closed by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants