Skip to content

net: Resolver appears to leak open files under NetBSD #78489

Description

@cheesestraws

Go version

go version go1.26.1 netbsd/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/cheesey/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/cheesey/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1401602467=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='netbsd'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/cheesey/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='netbsd'
GOPATH='/home/cheesey/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/cheesey/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/netbsd_amd64'                                                              GOVCS=''                                                                                                     GOVERSION='go1.26.1'                                                                                         GOWORK=''                                                                                                    PKG_CONFIG='pkg-config'

What did you do?

Ran:

package main

import (
        "context"
        "net"
        "log"
        "time"
)

func main() {
        t := time.NewTicker(1 * time.Second)
        for _ = range t.C {
                h, e := net.DefaultResolver.LookupCNAME(context.Background(), "thiscnamedoesnotexist")
                if e != nil {
                        log.Printf("e: %v", e)
                } else {
                        log.Printf("h: %s", h)
                }
        }
}

(whether the CNAME exists or not appears to be irrelevant)

What did you see happen?

the number of open files, as reported by

$ sudo lsof | grep main | wc -l

grows apparently unboundedly, with pairs of open files like

main    12639 cheesey  150u  KQUEUE 0xffffe165d2ed8340                   
main    12639 cheesey  151r    VREG              168,0        111 629104 /etc/

What did you expect to see?

No increase in number of open files, as verified on macOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions