Expand Windows DNS sync-query detection for inline-completing names - #130411
Merged
rzikm merged 5 commits intoJul 14, 2026
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix memory leak in DnsResolver for Windows 10/Server 2019
Expand Windows DNS sync-query detection for inline-completing names
Jul 9, 2026
rzikm
marked this pull request as ready for review
July 9, 2026 15:22
rzikm
approved these changes
Jul 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Windows System.Net.NameResolution DnsQueryEx workaround by expanding the set of query names treated as “known to complete synchronously” on affected Windows versions, and extends the existing regression test to exercise those names through both sync/async resolver entry points.
Changes:
- Replace the
localhost-only fast-path withIsSynchronouslyCompletingQueryName, including IP literal detection and additional special-case names. - Route those names directly through the synchronous DnsQueryEx path when running async on pre-22000 Windows versions.
- Expand the Windows regression test to cover the additional “synchronously completing” names.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/libraries/System.Net.NameResolution/src/System/Net/DnsResolverPal.Windows.cs | Broaden the pre-22000 async inline-completion workaround to a wider set of names via a new predicate. |
| src/libraries/System.Net.NameResolution/tests/FunctionalTests/DnsResolverTest.cs | Expand the existing Windows regression test to cover the broader set of synchronously-completing names. |
MichalPetryka
left a comment
Contributor
There was a problem hiding this comment.
Should we add an assert that we never got null and a memory leak here?
…n true on hostname failure, fix test data Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
…tion test Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
MihaZupan
approved these changes
Jul 13, 2026
Member
|
/ba-g System.Text.Json failures are unrelated |
rzikm
deleted the
copilot/dotnetruntime-130374-fix-dns-resolver-memory-leak
branch
July 14, 2026 10:35
eiriktsarpalis
pushed a commit
that referenced
this pull request
Jul 15, 2026
…130411) <!-- --> This broadens the Windows `DnsResolver` workaround for pre-22000 `DnsQueryEx` inline completion so it covers the full set of names the OS team identified as synchronously completing, not just `localhost`. The change keeps the existing async path for all other names and avoids the extra `DNS_QUERY_NO_WIRE_QUERY` probe. - **Behavior** - Route these names directly through the synchronous path on affected Windows versions: - IP literals - machine hostname - `loopback` - `localhost` - `..DnsServers` - `..localmachine` - **Implementation** - Replace the `localhost`-only check with a broader predicate for synchronously completing names. - Use `IPAddress.IsValid(...)` for allocation-free IP literal detection. - Compare against the current hostname without process-wide caching. - If hostname lookup fails, fall back to the normal async path rather than introducing a new failure mode. - **Regression coverage** - Expand the existing Windows regression test to cover the added synchronous-completion cases through both sync and async entry points. ```csharp if (IPAddress.IsValid(name)) { return true; } ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This broadens the Windows
DnsResolverworkaround for pre-22000DnsQueryExinline completion so it covers the full set of names the OS team identified as synchronously completing, not justlocalhost. The change keeps the existing async path for all other names and avoids the extraDNS_QUERY_NO_WIRE_QUERYprobe.Behavior
loopbacklocalhost..DnsServers..localmachineImplementation
localhost-only check with a broader predicate for synchronously completing names.IPAddress.IsValid(...)for allocation-free IP literal detection.Regression coverage