Repository navigation
fix(libScePosixForWebKit): use a numeric host as its canonical name when the host leaves it empty - #11859
Conversation
…hen the host leaves it empty FreeBSD's getaddrinfo sets ai_canonname to the numeric host itself when AI_CANONNAME is asked for a numeric address (explore_numeric, after RFC 3493), on every record it returns. glibc does it on the first record, and macOS leaves it null, so on macOS a guest got no canonical name for 127.0.0.1 or ::1. When AI_CANONNAME is asked and the node is a numeric IPv4 or IPv6 address, a record the host left without a canonical name gets the node's text.
|
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.
|
MarcZX10
left a comment
There was a problem hiding this comment.
I found one edge case in the numeric-name detection. The fallback recognizes IPv6 only when inet_pton(AF_INET6, node, ...) succeeds, which excludes scoped literals such as fe80::1%en0; I verified inet_pton rejects the scoped form while getaddrinfo accepts it. FreeBSD 11.4 handles the %scope suffix separately and passes the original hostname as the canonical name to its numeric-address path (see explore_numeric_scope in getaddrinfo.c). Could you cover scoped IPv6 with AI_CANONNAME too, or narrow the stated behavior? I have not reproduced the missing canonical name on macOS for this scoped form, so this is a coverage concern rather than a confirmed target failure. The focused Linux/macOS reports and existing checks otherwise look coherent; no independent resolver test was run locally.
…ic host for its canonical name A scoped literal such as fe80::1%1 is numeric for getaddrinfo, but inet_pton rejects the %scope suffix on glibc. Check the address before the suffix and keep the whole node as the canonical name, as FreeBSD's explore_numeric_scope passes the original hostname to explore_numeric.
|
@MarcZX10 thanks, covered in b97c5b6 (new commit, no force-push).
What I measured with a C probe:
So the change mainly stops the check from depending on how the host's Results:
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine. |
MarcZX10
left a comment
There was a problem hiding this comment.
The scoped IPv6 follow-up addresses the reported case and adds the requested regression. I spotted one allocation-failure edge in the new fallback: after getaddrinfo succeeds, constructing std::string address can throw std::bad_alloc before freeaddrinfo(native) runs. This function has no surrounding catch/RAII cleanup, so the exception can cross the C ABI and leak the host addrinfo list. Please consider using a bounded stack buffer for the IPv6 portion or an RAII owner for native (and map allocation failure to the function’s normal error result). I did not reproduce OOM; this is a source-level exception-safety finding. The focused resolver test passed under QEMU TCG on the exact head, but this local host required emulation because its CPU lacks the project’s AVX2/FMA requirement.
…ting in the canonical name fallback Copy the address part before %scope into a bounded stack buffer instead of a std::string, so the check after a successful host getaddrinfo cannot throw before freeaddrinfo and the exception cannot cross the C ABI. An address longer than the buffer is not a numeric IPv6 literal.
|
@MarcZX10 thanks, done in Linux (Ubuntu 26.04, GCC 15.2, Release): Written with AI assistance (Claude Code). I ran the builds and tests above on my machine. |
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tree also carried the open PRs #11945, #11899, #11772, #11087, #10789, #11627, #11354, all merged cleanly, so the run is a joint one; the tests of this PR are AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed — approved
The stack-buffer follow-up resolves the allocation-failure path I flagged, and the scoped numeric IPv6 case is now covered.
What I checked
- Reviewed exact head
c2a143da8050d1253f83abcf709072287919dd0bagainst livemain10bec5c322eb581b3e959e6c7e18bcf09e068e96. - The new fallback strips
%scopeonly for theinet_pton(AF_INET6)classification, keeps the originalnodeas the canonical name, and uses a fixed 64-byte stack buffer. It introduces no allocation between successfulgetaddrinfoandfreeaddrinfo. - Host-provided canonical names retain precedence. The existing numeric IPv4 fallback and the
AI_CANONNAME/AI_NUMERICHOSTmappings are consistent with the new branch. - Current-main merge preview is clean. The touched resolver and test files have not changed on
mainsince the PR base.
Results
| Check | Result |
|---|---|
| Current-main merge preview | Clean (92237d620cf093f8529753146a38b1b9cdf8c33e) |
| Diff check | Pass; no output |
| Conventions | Pass (All conventions checks passed.) |
| Focused Linux tests | Author reports guest_raw_resolver and guest_resolver passed 3/3 on the latest head |
| Focused Windows tests | Independent report says the PR test passed in a 14/14 test batch on the exact head, merged locally with its stated main and prerequisite PRs |
| Focused macOS tests | Author reports 3/3 on the earlier functional head; the final change only replaces the temporary string with a stack buffer and was not rerun on macOS |
| Hosted checks | Windows, conventions, labels, eligibility, and report pass; Linux and specialized product jobs skipped |
Raw local output
merge-base: 801d5b9bc11049e6274daca09d70690bd5b8d0a9
merge-tree: 92237d620cf093f8529753146a38b1b9cdf8c33e
All conventions checks passed.
git diff --check: no output (pass)
Negative control
The author reports the original macOS failure 3/3 and the fixed resolver test passing 3/3. Linux passes on the latest head. No separate mutation or forced-failure run is reported.
Findings
Blocking
None found in the scoped resolver change.
Non-blocking
I did not independently build or run the resolver tests. The runtime results above are author and independent-review reports. The final stack-buffer-only commit was not rerun on macOS.
Sources
Not verified
I did not run platform builds, CTest, title behavior, or console behavior locally. The macOS result applies to the preceding functional head, not the final stack-buffer-only commit.
To get this to a good state
No further change is required for the resolver correctness and exception-safety findings reviewed here.
|
Confirmed on a second Mac with today's
AI-assisted: yes |
What
guest_raw_resolveraborts on macOS withraw resolver: numeric canonical name differs:getaddrinfowithAI_CANONNAME|AI_NUMERICHOSTon127.0.0.1or::1returns no canonical name.FreeBSD 11.4's
explore_numericsetsai_canonnameto the numeric host itself whenAI_CANONNAMEis asked ("based on a clarification in RFC3493"), andcopy_aicarries it to every record. glibc sets it on the first record. macOS'sgetaddrinfoleaves it null for a numeric host, with or withoutAI_NUMERICHOST(a name such aslocalhostdoes get one). Measured with a plain C probe:getaddrinfowithAI_CANONNAME127.0.0.1,::1, datagram127.0.0.1,::1127.0.0.1, any socket type127.0.0.1, null, nullWhen the guest asks for
AI_CANONNAMEand the node is a numeric IPv4 (the sameinet_atonparsegethostbynameuses) or IPv6 address, orAI_NUMERICHOSTwas given, a record the host left without a canonical name now gets the node's text. On macOS that fixes every record; on Linux it only fills the later records of a multi-record numeric answer, as FreeBSD does. A host-provided name is never replaced.Tested
main801d5b9 plus the open macOS series (feat(libkernel): direct memory mappings on macOS hosts #7631, build(libkernel): compile Exception on macOS #11249, fix(libSceLibcInternal): declare environ for the spawn test on macOS #11358, build(libSceAudioIn): keep --exclude-libs off Apple's linker #10669, fix(libkernel): build the file, module and rtld calls on macOS hosts #10552, feat(libkernel): process, thread and clock queries on macOS hosts #7804, build(agc): compile Lifecycle, GuestMemory and GuestBufferMemory on macOS #11447, build(agc): keep the Linux-only parts of three AGC tests off macOS #11437, fix(agc): load the Vulkan loader and list MoltenVK on macOS #11554) needed to link.guest_raw_resolveraborts as above, 3 of 3.guest_raw_resolver.guest_raw_resolverpasses 3 of 3.tools/check_conventions.pypasses.Overlap: #5021 touches
Resolver.cpponly ingethostbyname, whichmainalready has;git merge-treemerges this branch with #5021 without a conflict in that file.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code