Avoid AI_ADDRCONFIG netlink path for DNS lookups (#560, #524)#589
Merged
Conversation
getAddrInfo always passed AI_ADDRCONFIG to getaddrinfo. That flag has two problematic consequences: - On glibc it enumerates the configured interfaces through a netlink socket (__check_pf). Under heavy threaded churn this path can abort the whole process from inside getaddrinfo (__netlink_assert_response), which is the crash reported in #560 -- reproduced while connecting to "127.0.0.1". - It only returns addresses for families that have a configured, non-loopback interface, so a host resolving to loopback (e.g. "localhost") fails to resolve when the machine is offline (#524). Two changes: 1. Detect numeric IP literals (via inet_pton) and use AI_NUMERICHOST instead of AI_ADDRCONFIG. There is no name to resolve, so we skip the netlink enumeration entirely -- directly avoiding the #560 abort for IP hosts and making literal lookups faster. 2. For real hostnames, retry getaddrinfo once without AI_ADDRCONFIG if the first attempt fails, so loopback names still resolve when offline (#524). Smoke-tested: 127.0.0.1, ::1, 8.8.8.8 and localhost all still resolve. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bsergean
added a commit
that referenced
this pull request
Jun 25, 2026
Release of accumulated fixes since v12.0.0: DNS lookup crash/offline resolution (#589), OpenSSL IP-address cert validation (#588), case-insensitive Upgrade header (#584), server fd double-close (#585), fragment buffering optimization (#562), and the install include-dir fix (#582). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Fixes #560
Fixes #524
Problem
DNSLookup::getAddrInfoalways passedAI_ADDRCONFIGtogetaddrinfo:That flag causes two distinct failures:
AI_ADDRCONFIGenumerates the configured interfaces through a netlink socket (__check_pf). Under heavy threaded churn that path can abort the whole process from insidegetaddrinfo(__netlink_assert_response→SIGABRT). The reported reproducer connects to127.0.0.1— a numeric literal that needs no name resolution at all.AI_ADDRCONFIGonly returns addresses for families with a configured non-loopback interface. With no network (cable unplugged / no wifi), evenlocalhostfails to resolve.Fix
inet_pton) now useAI_NUMERICHOSTand dropAI_ADDRCONFIG. There's no name to resolve, so glibc skips the netlink enumeration entirely — directly avoiding the Crash on DNS lookup #560 abort for IP hosts, and making literal lookups faster. This covers the exact127.0.0.1reproducer.AI_ADDRCONFIGfor its intended benefit, but if the firstgetaddrinfofails we retry once without it, so loopback-resolving names still work offline (Localhost DNS lookup fails without network connection #524). No new API/config knob required.Testing
-DUSE_TLS=ON -DUSE_OPEN_SSL=ON,CMAKE_CXX_STANDARD 11).DNSLookup::resolve:127.0.0.1,::1,8.8.8.8(numeric path) andlocalhost(AI_ADDRCONFIG path) all resolve correctly.Notes / scope
AI_ADDRCONFIGmore broadly, but that has IPv4/IPv6 selection trade-offs so I kept this change conservative.🤖 Generated with Claude Code