net: 1.19 DNS lookups broken on Windows if standard library built with CGO_ENABLED=0 #53490
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
release-blocker
Milestone
This bug is about the changes in Go 1.19 for DNS lookups on WIndows: https://go.dev/cl/409234 for #33097.
If the standard library is built with
CGO_ENABLED=0
, then in 1.18 we will still use the standard library on Windows, by calling functions likesyscall.GetAddrInfoW
. In both 1.18 and 1.19 building withCGO_ENABLED=0
will setnetGo = true
and will then setconfVal.netGo = true
. In 1.18 this has no real effect. In 1.19 this will mean thatconfVal.hostLookupOrder
will returnhostLookupDNS
on Windows. That in turn means that(*Resolver).preferGoOverWindows
will returntrue
. That means that we will use the Go DNS routines, not the Windows functions.Note that this can't be overridden by setting
GODEBUG=netdns=cgo
, as oncenetGo
is set at initialization time everything else follows. This is a reasonable choice on Unix systems where building withCGO_ENABLED=0
means that the cgo functions are simply not available, but it's not a reasonable choice on Windows where the functions are always available.One user-visible effect is that, since the Go lookup code on Windows has no way of looking at a /etc/hosts equivalent, looking up the address of
localhost
will fail.We should make sure that Windows DNS functions will do the right thing when built with
CGO_ENABLED=0
on Windows. I think they should default to using the Windows functions as before. That choice can be overridden withGODEBUG=netdns=go
or by building with-tags=purego
.Or perhaps here is a different approach we could take, but definitely by default looking up
localhost
should work.CC @bradfitz
The text was updated successfully, but these errors were encountered: