Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net: MacOS lookupIP resolves domains different if CGO_ENABLED flag used. #51753

Closed
mhaley-tignis opened this issue Mar 17, 2022 · 3 comments
Closed

Comments

@mhaley-tignis
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mhaley/Library/Caches/go-build"
GOENV="/Users/mhaley/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mhaley/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mhaley/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mhaley/src/testArea/go-dns-resolution/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0m/1mkvkqj94hs89nrkz765217c0000gn/T/go-build3158196937=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I ran a simple program building it with CGO_ENABLED=1 and CGO_ENABLED=0

$ CGO_ENABLED=1 go build -o dns-testing
$ ./dns-testing
Could not get IPs: lookup does-not-exist: no such host
$ CGO_ENABLED=0 go build -o dns-testing
$ ./dns-testing                        
Could not get IPs: lookup does-not-exist on 192.168.0.1:53: no such host

https://go.dev/play/p/kxxT6pToEDC

What did you expect to see?

I expected domain names to be resolved the same way in both cases.

What did you see instead?

When CGO_ENABLED=0 is set, the /etc/resolver config is ignored by the resolver.

@mhaley-tignis
Copy link
Author

@mhaley-tignis This issue is really about behavior on Linux. The resolver issues on macOS are quite different and are best handled elsewhere. In general on macOS, as far as I know, there is no way to combine CGO_ENABLED=0 and /etc/resolver. You have to pick one or the other.

Originally posted by @ianlancetaylor in #33019 (comment)

@ianlancetaylor what did you mean by "best handled elsewhere"? Did you mean open a new ticket, or is there a different way to resolve domains on MacOS so that this problem is not encountered?

@seankhliao
Copy link
Member

Duplicate of #12524

@seankhliao seankhliao marked this as a duplicate of #12524 Mar 17, 2022
@ianlancetaylor
Copy link
Member

Yes, I meant a new issue. But I see that @seankhliao correctly points out that there is already an issue for this.

@golang golang locked and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants