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

net: Misleading error "no such host" when running out of file descriptiors #56192

Open
polarina opened this issue Oct 13, 2022 · 6 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@polarina
Copy link
Contributor

polarina commented Oct 13, 2022

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

$ go version
go version go1.19.2 linux/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="/home/mce-gabrielp/.cache/go-build"
GOENV="/home/mce-gabrielp/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/mce-gabrielp/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mce-gabrielp/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build969251111=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Given the following program:

package main

import "net/http"

func main() {
	for {
		_, err := http.DefaultClient.Get("https://google.com")
		if err != nil {
			panic(err)
		}
	}
}

Then build and execute as follows:

$ go build main.go 
$ bash -c 'ulimit -n 6 && ./main'

We initially encountered this bug in a production program (where, due to our bug, a request got repeated in a loop without closing the response body) with far more gracious ulimit. This is not a fringe case limited to setting the ulimit haphazardly low.

What did you expect to see?

panic: Get "https://google.com": dial tcp: lookup google.com: too many open files

What did you see instead?

panic: Get "https://google.com": dial tcp: lookup google.com: no such host
@joedian joedian added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 14, 2022
@mateusz834
Copy link
Contributor

mateusz834 commented Oct 16, 2022

It only happens with the cgo resolver, while using the go resolver it returns the correct error: lookup google.com on [::1]:53: dial udp [::1]:53: socket: too many open files

@gopherbot
Copy link

gopherbot commented Oct 16, 2022

Change https://go.dev/cl/443255 mentions this issue: net: cgo resolver return correctly the too many open files error

@nightlyone
Copy link
Contributor

nightlyone commented Oct 18, 2022

@mateusz834 could you please mention which libc and version of it you are using?

https://dev.to/0xbf/how-to-get-glibc-version-c-lang-26he describes how to do that for glibc.

@mateusz834
Copy link
Contributor

mateusz834 commented Oct 18, 2022

@nightlyone (GNU libc) 2.36

@mateusz834
Copy link
Contributor

mateusz834 commented Oct 23, 2022

As discussed in CL 443255 this is caused by a glibc bug. I filled a bug report here: https://sourceware.org/bugzilla/show_bug.cgi?id=29717

@mateusz834
Copy link
Contributor

mateusz834 commented Oct 23, 2022

For now it can be workarounded by forcing the go resolver, or using different libc (musl).

@seankhliao seankhliao added this to the Backlog milestone Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants