Skip to content

starboard: Translate getaddrinfo() error codes - #13246

Merged
andrewsavage1 merged 2 commits into
youtube:mainfrom
ogarai:nplb/fix_getaddrinfo_error_codes
Oct 16, 2026
Merged

andrewsavage1 merged 2 commits into
youtube:mainfrom
ogarai:nplb/fix_getaddrinfo_error_codes

Conversation

@ogarai

@ogarai ogarai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

The getaddrinfo() wrapper returned the platform's error codes as is, while Cobalt expects musl's. On AOSP an unknown name returned bionic's EAI_NODATA (7) instead of musl's (-5), so Cobalt reported a generic resolution failure.

Translate the codes, and free the results when converting one fails.

Test: The new nplb test RainyDayUnknownHostname passes. It failed before with result 7.

Bug: 532158865

The getaddrinfo() wrapper returned the platform's error codes as is,
while Cobalt expects musl's. On AOSP an unknown name returned bionic's
EAI_NODATA (7) instead of musl's (-5), so Cobalt reported a generic
resolution failure.

Translate the codes, and free the results when converting one fails.

Test: The new nplb test RainyDayUnknownHostname passes. It failed
before with result 7.

Bug: 532158865
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ⏳ PENDING Checks are running
CI / android ✅ PASS Passed
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ⏳ PENDING Checks are running
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


starboard: Translate getaddrinfo error codes

The getaddrinfo wrapper previously returned platform-specific error
codes directly. Cobalt expects musl-compatible error codes within its
modular layer. On Android, for example, Bionic returns EAI_NODATA as 7,
whereas musl expects -5. This difference caused Cobalt to report
generic resolution failures instead of specific errors.

This change translates platform EAI error codes to their musl
equivalents. It also fixes a potential memory leak by ensuring results
are freed if the addrinfo conversion fails.

Bug: 532158865

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new test for resolving unknown hostnames and adds error code mapping from platform to musl in the POSIX socket ABI wrappers, alongside improved resource cleanup on conversion failures. The review feedback highlights critical issues regarding potential memory leaks when freeing musl_ai directly, and compilation failures on platforms where EAI_NODATA is deprecated or undefined, suggesting preprocessor guards to ensure portability.

@ogarai
ogarai requested a review from andrewsavage1 October 9, 2026 20:43
@andrewsavage1
andrewsavage1 enabled auto-merge (squash) October 15, 2026 20:28
@andrewsavage1
andrewsavage1 merged commit d8e5769 into youtube:main Oct 16, 2026
1543 of 1584 checks passed
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 16, 2026
Refer to original PR: #13246

The getaddrinfo() wrapper returned the platform's error codes as is,
while Cobalt expects musl's. On AOSP an unknown name returned bionic's
EAI_NODATA (7) instead of musl's (-5), so Cobalt reported a generic
resolution failure.

Translate the codes, and free the results when converting one fails.

Test: The new nplb test RainyDayUnknownHostname passes. It failed before
with result 7.

Bug: 532158865

(cherry picked from commit d8e5769)
briantting pushed a commit that referenced this pull request Oct 20, 2026
Refer to original PR: #13246

The getaddrinfo() wrapper returned the platform's error codes as is,
while Cobalt expects musl's. On AOSP an unknown name returned bionic's
EAI_NODATA (7) instead of musl's (-5), so Cobalt reported a generic
resolution failure.

Translate the codes, and free the results when converting one fails.

Test: The new nplb test RainyDayUnknownHostname passes. It failed before
with result 7.

Bug: 532158865

(cherry picked from commit d8e5769)
briantting pushed a commit that referenced this pull request Oct 20, 2026
Refer to original PR: #13246

The getaddrinfo() wrapper returned the platform's error codes as is,
while Cobalt expects musl's. On AOSP an unknown name returned bionic's
EAI_NODATA (7) instead of musl's (-5), so Cobalt reported a generic
resolution failure.

Translate the codes, and free the results when converting one fails.

Test: The new nplb test RainyDayUnknownHostname passes. It failed before
with result 7.

Bug: 532158865

(cherry picked from commit d8e5769)
@ogarai
ogarai deleted the nplb/fix_getaddrinfo_error_codes branch November 4, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants