golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.29k stars 17.57k forks source link

cmd/go: panic: LoadImport called with empty package path [recovered] when building source #67984

Closed MikeMitchellWebDev closed 1 month ago

MikeMitchellWebDev commented 3 months ago

Go version

go version go1.22.0 darwin/amd64

Output of go env in your module/workspace:

go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/mm/Library/Caches/go-build'
GOENV='/Users/mm/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mm/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mm/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='/usr/bin/clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/mm/go/src/github.com/MikeMitchellWebDev/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/go-build434803499=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I tried to time how long it takes to build the Go source code (which I didn't alter at all) by running time ./make.bash from the src dir of the repository as the Go blog instructs. The first time it built successfully, and then I ran the same build command two other times and the build process failed each time

On another version of the Go source code (which I had, incidentally, altered minimally) running time ./make.bash ran successfully two times in a row.

What did you see happen?

1st time

time ./make.bash Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64) Building Go toolchain1 using /usr/local/go. Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1. Building Go toolchain2 using go_bootstrap and Go toolchain1. Building Go toolchain3 using go_bootstrap and Go toolchain2. Building packages and commands for darwin/amd64.

Installed Go for darwin/amd64 in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3 Installed commands in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/bin *** You need to add /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/bin to your PATH.

real 10m14.007s user 17m17.838s sys 2m58.189s

2nd time

time ./make.bash Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64) Building Go toolchain1 using /usr/local/go. Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1. Building Go toolchain2 using go_bootstrap and Go toolchain1. Building Go toolchain3 using go_bootstrap and Go toolchain2. Building packages and commands for darwin/amd64. panic: LoadImport called with empty package path [recovered] panic: LoadImport called with empty package path

goroutine 1 [running]: cmd/go/internal/load.(preload).flush(0xc0006317f0) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1082 +0x74 panic({0x1442c00?, 0x1590cd0?}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/runtime/panic.go:785 +0x132 cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0x0, {0xc000dc263d, ...}, ...) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:681 +0x13e5 cmd/go/internal/load.(Package).load(0xc001860008, {0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0003ea97d, ...}, ...) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1969 +0x1a6e cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0xc0006317f0, {0xc0003ea97d, ...}, ...) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:744 +0x52f cmd/go/internal/load.PackagesAndErrors({0x1596200?, 0x18462e0?}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0000220b0, 0x1, ...}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:2837 +0xa0b cmd/go/internal/work.runInstall({0x1596200, 0x18462e0}, 0xc00002a348?, {0xc0000220b0, 0x1, 0x1}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/work/build.go:696 +0x1fd main.invoke(0x181b380, {0xc0000220a0, 0x2, 0x2}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:298 +0x6e3 main.main() /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:212 +0xabc go tool dist: FAILED: /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/pkg/tool/darwin_amd64/go_bootstrap install std: exit status 2

real 7m33.434s user 9m49.533s sys 1m48.451s

3rd time

time ./make.bash Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64) Building Go toolchain1 using /usr/local/go. Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1. Building Go toolchain2 using go_bootstrap and Go toolchain1. Building Go toolchain3 using go_bootstrap and Go toolchain2. Building packages and commands for darwin/amd64. panic: LoadImport called with empty package path [recovered] panic: LoadImport called with empty package path

goroutine 1 [running]: cmd/go/internal/load.(preload).flush(0xc000036f20) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1082 +0x74 panic({0x1442c00?, 0x1590cd0?}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/runtime/panic.go:785 +0x132 cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0x0, {0x65db63d, ...}, ...) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:681 +0x13e5 cmd/go/internal/load.(Package).load(0xc0016f0008, {0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0003de19d, ...}, ...) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:1969 +0x1a6e cmd/go/internal/load.loadImport({0x1596200, 0x18462e0}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, 0xc000036f20, {0xc0003de19d, ...}, ...) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:744 +0x52f cmd/go/internal/load.PackagesAndErrors({0x1596200?, 0x18462e0?}, {0x0, 0x0, 0x0, 0x1, 0x0, 0x0}, {0xc0000a20b0, 0x1, ...}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/load/pkg.go:2837 +0xa0b cmd/go/internal/work.runInstall({0x1596200, 0x18462e0}, 0xc0000b42d0?, {0xc0000a20b0, 0x1, 0x1}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/internal/work/build.go:696 +0x1fd main.invoke(0x181b380, {0xc0000a20a0, 0x2, 0x2}) /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:298 +0x6e3 main.main() /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/src/cmd/go/main.go:212 +0xabc go tool dist: FAILED: /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_3/pkg/tool/darwin_amd64/go_bootstrap install std: exit status 2

real 4m52.105s user 8m45.084s sys 1m30.284s Michaels-MacBook-Pro-3:src mm$ go bug go: downloading go1.23 (darwin/amd64) go: download go1.23 for darwin/amd64: toolchain not available Michaels-MacBook-Pro-3:src mm$ go env go: downloading go1.23 (darwin/amd64) go: download go1.23 for darwin/amd64: toolchain not available

What did you expect to see?

I expected the build to run successfully each time (as it did on the source code that I did alter)


Michaels-MacBook-Pro-3:src mm$ time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2
Installed commands in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin
*** You need to add /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin to your PATH.

real    5m40.768s
user    9m55.416s
sys 1m43.497s
Michaels-MacBook-Pro-3:src mm$ time ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/amd64.
---
Installed Go for darwin/amd64 in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2
Installed commands in /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin
*** You need to add /Users/mm/go/src/github.com/MikeMitchellWebDev/go_source_june_13_clean_2/bin to your PATH.

real    5m30.650s
user    9m22.241s
sys 1m37.025s
MikeMitchellWebDev commented 3 months ago

Similar to https://github.com/golang/go/issues/60230

gabyhelp commented 3 months ago

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

dr2chase commented 3 months ago

I tried, with a very similar configuration (Darwin-amd64, using 1.22.4 as the building compiler, building at tip, similar settings in goenv), but could not reproduce.

MikeMitchellWebDev commented 3 months ago

I tried, with a very similar configuration (Darwin-amd64, using 1.22.4 as the building compiler, building at tip, similar settings in goenv), but could not reproduce.

It doesn’t always reproduce for me. I’ve tried it several times since filing the issue.

MikeMitchellWebDev commented 3 months ago

As stated in the OP, I compared the build times of two versions of source, one which I altered, one which I didn't. In case there's a possibility that I misreported which one failed, the alteration to the source that I made resulted in the following pull request, which obviously can't be responsible for the type of failure reported in this issue. https://go-review.googlesource.com/c/go/+/592735

matloob commented 3 months ago

@MikeMitchellWebDev at which commit were you running make.bash? I understand the build doesn't fail reliably, but are you still able to reproduce occasionally?

MikeMitchellWebDev commented 3 months ago

I was running make.bash at commit 6d93de2c110f66457f103c33ba496ff2e2bf33af . I ran time ./make.bash twice today at commit ea537cca314d9da5365eeefcc375410c76e93b36 without any failures.

matloob commented 3 months ago

I tried running make.bash at 6d93de2c110f66457f103c33ba496ff2e2bf33af using a Go 1.22.4 bootstrap toolchain and wasn't able to reproduce. It seems like we should close this and reopen if you see the issue pop up again?

If we could get reproduction instructions that will cause the failures to happen, say, once in every five or so attempts, if not consistently, that would be useful for us to diagnose and fix.

gopherbot commented 1 month ago

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)