Repository navigation
fix(libkernel): send to INADDR_ANY through 127.0.0.1 on macOS - #17878
Conversation
On macOS a datagram sent to 0.0.0.0 or ::ffff:0.0.0.0 failed with EHOSTUNREACH, so guest_socket_port_zero failed at "sendto INADDR_ANY must reach 127.0.0.1". FreeBSD 11.4 picks a local address for an unspecified IPv4 destination. sendto on macOS now maps the unspecified destination to 127.0.0.1 through LoopbackForUnspecifiedInet, the helper the Windows path already uses. connect is unchanged because macOS already reaches the local host there.
|
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.
|
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
kurexw
left a comment
There was a problem hiding this comment.
Tested on macOS 27.2, Apple Silicon (M4), full build (x86-64 under Rosetta 2). This PR was merged alone onto main 04f7633 with git merge --no-ff. I ran the 56 socket and net tests (guest_socket_*, guest_poll, guest_refused_connect, guest_sce_net, guest_net_*, guest_kernel_socket*) three times on main and three times with this PR.
guest_socket_port_zerofails in all three runs onmain("sendto INADDR_ANY must reach 127.0.0.1 (errno 65)") and passes in all three runs with this PR.- No other test changes. In one run,
guest_socket_read_writefailed withECONNRESET. That test is flaky onmaintoo (1 failure in 10 runs onmain, 0 in 10 with this PR), so this PR is not the cause. - This PR and #17879 conflict in
core/libs/prx/libkernel/Socket/src/Udp.cpp, so whichever merges second needs a rebase.
|
Tested on an Apple M1 (macOS 26.5, Apple clang 21.0.0), x86_64 Release under Rosetta 2. The tree was
AI-assisted: yes (Claude Code) |
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change applies the existing unspecified-address loopback mapping to Darwin sendto and the inspected implementation covers IPv4 and IPv4-mapped IPv6.
What I ran
Reviewed head 0a7cf3a1d353f2c325c9e5d267dae841fde38b6f. No commands or tests were run; the author-reported test results were not independently verified.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | One changed source file read |
| Tests | not run | No tests run during review |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author reports macOS test results in the PR description; they were not independently confirmed. files.json was unavailable in the provided review bundle, so I could not compare the read files against its reviewed list. No test, build, or platform behavior was run. Read: description.md, commits.md, manifest.json, diff.patch, and core/libs/prx/libkernel/Socket/src/Udp.cpp lines 400–460 and 1990–2029. Excluded: no paths were available from files.json.
To get this to a good state
Nothing is required.
NobleBrains
left a comment
There was a problem hiding this comment.
Confirmed on macOS 15.
Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta, BUILD_TESTING=ON. These are the OS and compiler generation of the macos-15 runner.
Tree: main 93d64f2d1e + the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (main does not build on macOS without them, see #28168), + #22091, #28369, #28075, #28076, #28284, then #17878, #20161, #25134, #26806, #22932, #28373, #27828, #27950, #27582, #24311 merged one after another. All merged cleanly.
guest_socket_port_zero |
failures |
|---|---|
| same tree before this PR | 3/3 |
with this PR at 0a7cf3a1d3 |
0/5 |
Full ctest -j 6 after all of them: 7047/7066 pass. Compared with the run before the second group of merges, no test fails that passed before.
AI-assisted: yes (Claude Code)
ligmaSec
left a comment
There was a problem hiding this comment.
The existing guest_socket_port_zero regression passed with this head integrated on Linux. The changed branch reuses the established IPv4 and IPv4-mapped loopback conversion for Darwin sendto. The conversion itself still needs a macOS run.
AI-assisted: yes.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head 56d2119552631118a9c0ab2bd15d8a4bad1c54d7. I read the prepared description, commits, manifest, diff, and the changed file’s relevant helper, address conversion, sendto, and connect sections with repo_read.py. No tests or builds were run.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Mapping is limited to unspecified IPv4 destinations and IPv4-mapped IPv6 destinations. |
| Tests and build | not run | The author reports macOS test results; I did not independently verify them. |
Negative control
Not run; no test was run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Udp.cppat the reviewed commit defines the IPv4 and IPv4-mapped IPv6 loopback conversion.Udp.cppat the reviewed commit applies it in the Darwinsendtopath.
Not verified
The reported macOS test results and behavior on physical consoles were not independently verified. The reviewed file was core/libs/prx/libkernel/Socket/src/Udp.cpp; files.json lists no excluded files.
To get this to a good state
Nothing is required.
What
On macOS, a datagram sent to
0.0.0.0or::ffff:0.0.0.0fails withEHOSTUNREACH(65). This makesguest_socket_port_zerofail. The change applies AnyPS5's existing loopback mapping to these destinations in the Darwinsendtopath, matching the mapping used on Windows by #15782.FreeBSD 11.4's
in_pcbconnect_setupselects the first local IPv4 address for an unspecified destination. Loopback is AnyPS5's approximation for this case. Theconnectpath already passes the guest test on macOS and is unchanged.Tested
Apple M4 (Mac16,13), macOS 27.2, Release x86-64 under Rosetta 2. CTest ran serially with the final v4 diffs on Mac integration stack
b05b1c4c93a2(main02452319with Mac build fixes). The review commit is based on main7259cce111.guest_socket_port_zerofails with errno 65.guest_socket_port_zeropasses. The separateguest_socket_optionsfailure remains.::ffff:0.0.0.0.guest_net_raw_protocol), andguest_sce_nethits the known epoll closed-stream failure.Checklist
main; no other open PR implements the same changeSummary by CodeRabbit