Skip to content

DNS localhost subdomain tests with AddressFamily fail on Android #124751

@rzikm

Description

@rzikm

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1304943
Build error leg or test failing: System.Net.NameResolution.Tests.GetHostEntryTest.DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily, System.Net.NameResolution.Tests.GetHostAddressesTest.DnsGetHostAddresses_LocalhostSubdomain_RespectsAddressFamily

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": "LocalhostSubdomain_RespectsAddressFamily",
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Description

The DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily and DnsGetHostAddresses_LocalhostSubdomain_RespectsAddressFamily tests (introduced in PR #123076 for RFC 6761 localhost subdomain handling) consistently fail on Android CI (windows.11.amd64.android.open queue).

Error

System.Net.Sockets.SocketException : hostname nor servname provided, or not known
   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ...)
   at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ...)
   at System.Net.Dns.GetHostEntryCore(String hostName, AddressFamily addressFamily, ...)
   at System.Net.Dns.GetHostEntry(String hostNameOrAddress, AddressFamily family)

Analysis

  • The tests call e.g. Dns.GetHostEntry("test.localhost", AddressFamily.InterNetwork) (or InterNetworkV6).
  • The RFC 6761 implementation tries the OS resolver for "test.localhost" first, then falls back to resolving plain "localhost" with the same AddressFamily.
  • The double GetHostEntryOrAddressesCore in the stack trace confirms the fallback triggers but also fails.
  • The fallback calls getaddrinfo("localhost", ..., ai_family) with a specific address family (AF_INET or AF_INET6). On Android, this may fail (EAI_NONAME) while getaddrinfo("localhost", ..., AF_UNSPEC) succeeds.
  • Other localhost subdomain tests that use AddressFamily.Unspecified (e.g. ReturnsLoopback) pass on Android.
  • There are no non-[OuterLoop] tests that call Dns.GetHostEntry("localhost", AddressFamily.InterNetwork) directly to confirm if family-specific localhost resolution works on Android in general.

CI Data (last 14 days, main branch)

Build GetHostEntry failures GetHostAddresses failures
1303735 3 3
1304312 1 1
1304943 2 2

Each Android job has exactly 1 failure per test (the test has 2 InlineData values: InterNetwork and InterNetworkV6), suggesting only one address family variant fails per run.

Console log example

https://helixr1107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-heads-main-76f79e897d5246b58a/System.Net.NameResolution.Functional.Tests/1/console.858b3560.log?helixlogtype=result

Possible fixes

  1. Fix the fallback to resolve "localhost" with AddressFamily.Unspecified and then filter results by the requested family.
  2. Investigate whether family-specific getaddrinfo("localhost", AF_INET/AF_INET6) is expected to work on Android and fix the emulator setup.

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1304943
Error message validated: [LocalhostSubdomain_RespectsAddressFamily]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 2/23/2026 12:30:22 PM UTC

Report

Build Definition Test Pull Request
1304943 dotnet/runtime System.Net.NameResolution.Functional.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 1 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions