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

cmd/go: panic when building prometheus/node_exporter (gotip) #45173

Closed
leitzler opened this issue Mar 23, 2021 · 2 comments
Closed

cmd/go: panic when building prometheus/node_exporter (gotip) #45173

leitzler opened this issue Mar 23, 2021 · 2 comments

Comments

@leitzler
Copy link
Contributor

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

$ go version
go version devel +f4b9183 Tue Mar 23 05:12:39 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

No, it is gotip specific.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pontus/.cache/go-build"
GOENV="/home/pontus/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pontus/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pontus/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/pontus/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/pontus/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel +f4b9183 Tue Mar 23 05:12:39 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/tmp.U5bdCsru30/node_exporter/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1079058336=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tried to build github.com/prometheus/node_exporter using gotip.

$ cd $(mktemp -d)
$ git clone https://github.com/prometheus/node_exporter
$ cd node_exporter/
$ git co 1dfd858
$ go build .
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x5b0bbe]

goroutine 781 [running]:
go/build.(*Context).eval(0xdc8720, 0x0, 0x0, 0xc00079e2d0, 0x0)
	/home/pontus/sdk/gotip/src/go/build/build.go:1852 +0x7e
go/build.(*Context).shouldBuild(0xdc8720, 0xc0007b8400, 0x89, 0x100, 0xc00079e2d0, 0x0, 0x0, 0x7f36d4f821d8)
	/home/pontus/sdk/gotip/src/go/build/build.go:1540 +0x4bc
go/build.(*Context).matchFile(0xdc8720, 0xc00095c000, 0x58, 0xc000270159, 0x19, 0xc00079e2d0, 0x0, 0xc000474100, 0xc000808990, 0x0, ...)
	/home/pontus/sdk/gotip/src/go/build/build.go:1425 +0xadf
go/build.(*Context).Import(0xdc8720, 0xa45148, 0x1, 0xc00050c1e0, 0x58, 0x0, 0xc000545c98, 0x4766ea, 0x9af620)
	/home/pontus/sdk/gotip/src/go/build/build.go:830 +0x239e
go/build.(*Context).ImportDir(...)
	/home/pontus/sdk/gotip/src/go/build/build.go:471
cmd/go/internal/load.loadPackageData.func2(0xdc7a60, 0x992f80)
	/home/pontus/sdk/gotip/src/cmd/go/internal/load/pkg.go:837 +0x2a5
cmd/go/internal/par.(*Cache).Do(0xdc7a60, 0x992f80, 0xc0003a6f90, 0xc000545ea8, 0x9ea8e0, 0xc00079e0c0)
	/home/pontus/sdk/gotip/src/cmd/go/internal/par/work.go:128 +0x10e
cmd/go/internal/load.loadPackageData(0xc0005c90b1, 0x1f, 0xc00024aea1, 0x2d, 0xc0005c9320, 0x2b, 0xc000028004, 0x21, 0x90ef1600, 0x1, ...)
	/home/pontus/sdk/gotip/src/cmd/go/internal/load/pkg.go:829 +0x445
cmd/go/internal/load.(*preload).preloadImports.func1(0xc0001bb800, 0x0, 0xc00021c030, 0xc0005c90b1, 0x1f)
	/home/pontus/sdk/gotip/src/cmd/go/internal/load/pkg.go:987 +0x9f
created by cmd/go/internal/load.(*preload).preloadImports
	/home/pontus/sdk/gotip/src/cmd/go/internal/load/pkg.go:986 +0x1c6

It could be close related to #44487, but a grep in the repo didn't show any empty build tags so I think this is a separate issue.

What did you expect to see?

No panic.

What did you see instead?

Panic.

@mvdan
Copy link
Member

mvdan commented Mar 23, 2021

I debugged a little, it is indeed caused by an empty build tag. Probably in a dependency? I didn't dig deeper as it seems like the other issue has a fix nearly ready to go, which will most likely fix this case too.

@leitzler
Copy link
Contributor Author

Oh, didn't think about dependencies. Thank you for the investigation!

Closing as duplicate of #44487

@golang golang locked and limited conversation to collaborators Mar 23, 2022
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

3 participants