Skip to content

go/test: coverage test fails with "error generating coverage report: write tmp: file already closed" with golang 1.20 #59938

@bitoku

Description

@bitoku

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

❯ podman run --rm -it -v $PWD:/v -w /v/plugin/file/tree golang:1.20.4 sh -c 'go version'
go version go1.20.4 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
❯ podman run --rm -it -v $PWD:/v -w /v/plugin/file/tree golang:1.20.4 sh -c 'go env'
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/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.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/v/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build236938569=/tmp/go-build -gno-record-gcc-switches"

on podman intel macOS

What did you do?

with golang 1.20, coverage test of coredns/plugin/file/tree fails with error error generating coverage report: write tmp: file already closed.
with golang 1.19, it doesn't fail.

This is a recipe for reproducing the error.

$ git clone git@github.com:bitoku/coredns.git
$ cd coredns
$ podman run --rm -it -v $PWD:/v -w /v/plugin/file/tree golang:1.20.4 sh -c 'go test -covermode=atomic -race ./...'
go: downloading github.com/miekg/dns v1.1.53
go: downloading golang.org/x/net v0.9.0
go: downloading golang.org/x/sys v0.7.0
error generating coverage report: write tmp: file already closed
FAIL	github.com/coredns/coredns/plugin/file/tree	0.029s
FAIL

This is reproducible with local golang (go version go1.20.3 darwin/amd64)

$ git clone git@github.com:bitoku/coredns.git
$ cd coredns/plugin/file/tree
$ go test -covermode=atomic -race ./...
error generating coverage report: write tmp: file already closed
FAIL	github.com/coredns/coredns/plugin/file/tree	0.466s
FAIL

Other coverage tests don't fail.

see coredns/coredns#6067 (comment) for reference.

What did you expect to see?

with golang 1.19.9

$ podman run --rm -it -v $PWD:/v -w /v/plugin/file/tree golang:1.19.9 sh -c 'go test -covermode=atomic -race ./...'
go: downloading github.com/miekg/dns v1.1.53
go: downloading golang.org/x/net v0.9.0
go: downloading golang.org/x/sys v0.7.0
ok  	github.com/coredns/coredns/plugin/file/tree	0.027s

What did you see instead?

with golang 1.20.4

$ podman run --rm -it -v $PWD:/v -w /v/plugin/file/tree golang:1.20.4 sh -c 'go test -covermode=atomic -race ./...'
go: downloading github.com/miekg/dns v1.1.53
go: downloading golang.org/x/net v0.9.0
go: downloading golang.org/x/sys v0.7.0
error generating coverage report: write tmp: file already closed
FAIL	github.com/coredns/coredns/plugin/file/tree	0.029s
FAIL

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions