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

Closed
polarina opened this issue Oct 13, 2022 · 7 comments
Closed
Labels
FrozenDueToAge 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

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
Member

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

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

@nightlyone
Copy link
Contributor

@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
Member

@nightlyone (GNU libc) 2.36

@mateusz834
Copy link
Member

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
Member

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
@bcmills
Copy link
Contributor

bcmills commented Jan 31, 2023

Duplicate of #18588

@bcmills bcmills marked this as a duplicate of #18588 Jan 31, 2023
@bcmills bcmills closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2023
@golang golang locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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.

7 participants