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

x/tools/go/packages: panic loading with LoadTypes #31163

Closed
mmcloughlin opened this issue Mar 30, 2019 · 6 comments
Closed

x/tools/go/packages: panic loading with LoadTypes #31163

mmcloughlin opened this issue Mar 30, 2019 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mmcloughlin
Copy link
Contributor

This issue appears to be a recurrence of #26834.

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

$ go version
go version go1.12 darwin/amd64

Does this issue reproduce with the latest release?

Haven't tried.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/michaelmcloughlin/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/michaelmcloughlin/gocode"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/p5/84p384bs42v7pbgfx0db9gq80000gn/T/go-build218012741=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ gopackages -mode=types math

What did you expect to see?

Successful package load and some related output.

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1182b2c]

goroutine 33 [running]:
go/types.(*Checker).handleBailout(0xc0000d40f0, 0xc00051bd08)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/check.go:240 +0x98
panic(0x126a0a0, 0x14b9aa0)
	/usr/local/Cellar/go/1.12/libexec/src/runtime/panic.go:522 +0x1b5
go/types.(*StdSizes).Sizeof(0x0, 0x13089c0, 0x14ba700, 0x113818e)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/sizes.go:154 +0x1bc
go/types.(*Config).sizeof(0xc000485d40, 0x13089c0, 0x14ba700, 0xc000018101)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/sizes.go:245 +0x51
go/types.representableConst(0x130c140, 0xc000018120, 0xc0000d40f0, 0x14ba700, 0xc0000f9fe8, 0x43b1300)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:230 +0x29a
go/types.(*Checker).representable(0xc0000d40f0, 0xc0000f9fc0, 0x14ba700)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:335 +0x69
go/types.(*Checker).convertUntyped(0xc0000d40f0, 0xc0000f9fc0, 0x13089c0, 0x14ba700)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:517 +0x977
go/types.(*Checker).shift(0xc0000d40f0, 0xc0000f9ec0, 0xc0000f9fc0, 0xc00031e480, 0x14)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:665 +0xa39
go/types.(*Checker).binary(0xc0000d40f0, 0xc0000f9ec0, 0xc00031e480, 0x130ae00, 0xc000315840, 0x130ae00, 0xc000315860, 0x14)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:792 +0xb59
go/types.(*Checker).exprInternal(0xc0000d40f0, 0xc0000f9ec0, 0x130ae40, 0xc00031e480, 0x0, 0x0, 0x1)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:1503 +0x1f1f
go/types.(*Checker).rawExpr(0xc0000d40f0, 0xc0000f9ec0, 0x130ae40, 0xc00031e480, 0x0, 0x0, 0x0)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:982 +0x81
go/types.(*Checker).multiExpr(0xc0000d40f0, 0xc0000f9ec0, 0x130ae40, 0xc00031e480)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:1599 +0x58
go/types.(*Checker).expr(0xc0000d40f0, 0xc0000f9ec0, 0x130ae40, 0xc00031e480)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/expr.go:1593 +0x49
go/types.(*Checker).constDecl(0xc0000d40f0, 0xc00007fb00, 0x0, 0x0, 0x130ae40, 0xc00031e480)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/decl.go:360 +0x129
go/types.(*Checker).objDecl(0xc0000d40f0, 0x130f240, 0xc00007fb00, 0x0)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/decl.go:201 +0x719
go/types.(*Checker).packageObjects(0xc0000d40f0)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/resolver.go:588 +0x25d
go/types.(*Checker).checkFiles(0xc0000d40f0, 0xc000178480, 0x2d, 0x2d, 0x0, 0x0)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/check.go:254 +0xa5
go/types.(*Checker).Files(...)
	/usr/local/Cellar/go/1.12/libexec/src/go/types/check.go:245
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc0000c6500, 0xc0001488c0)
	/Users/michaelmcloughlin/gocode/src/golang.org/x/tools/go/packages/packages.go:811 +0x52f
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
	/Users/michaelmcloughlin/gocode/src/golang.org/x/tools/go/packages/packages.go:669 +0x17f
sync.(*Once).Do(0xc0001488d0, 0xc000031f80)
	/usr/local/Cellar/go/1.12/libexec/src/sync/once.go:44 +0xb3
golang.org/x/tools/go/packages.(*loader).loadRecursive(0xc0000c6500, 0xc0001488c0)
	/Users/michaelmcloughlin/gocode/src/golang.org/x/tools/go/packages/packages.go:656 +0x67
golang.org/x/tools/go/packages.(*loader).refine.func2(0xc0000c6500, 0xc00012b030, 0xc0001488c0)
	/Users/michaelmcloughlin/gocode/src/golang.org/x/tools/go/packages/packages.go:594 +0x35
created by golang.org/x/tools/go/packages.(*loader).refine
	/Users/michaelmcloughlin/gocode/src/golang.org/x/tools/go/packages/packages.go:593 +0xd83
@mmcloughlin
Copy link
Contributor Author

I noticed this due to a panic in my CI tests. Based on when the CI job failed and a basic test on my machine I think golang/tools@dbeab5a may have introduced a problem.

@gopherbot
Copy link

Change https://golang.org/cl/170016 mentions this issue: go/packages: add NeedTypesSizes to LoadTypes

@ianthehat
Copy link

I think there is a second related bug, it should be possible to set any of the Need bits and the system will make sure it collects the pre-requisites, the Need bits only say what should be filled in in the output. For this panic to occur it was not correctly getting the sizes when asked for types, like it should.

@ianthehat ianthehat reopened this Mar 30, 2019
@ianthehat ianthehat added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 30, 2019
@gopherbot
Copy link

Change https://golang.org/cl/170342 mentions this issue: go/packages: make sure TypesSizes are requested when Types are

listx added a commit to listx/golangci-lint that referenced this issue Apr 20, 2019
This brings in the upstream fix
golang/tools@1aadbdf. (Upstream
issue is golang/go#31163).

To create this commit, I did:

  vgo get golang.org/x/tools
  make update_deps
  cd cmd/golangci-lint
  go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'"

Fixes golangci#500
jirfag pushed a commit to golangci/golangci-lint that referenced this issue Apr 20, 2019
This brings in the upstream fix
golang/tools@1aadbdf. (Upstream
issue is golang/go#31163).

To create this commit, I did:

  vgo get golang.org/x/tools
  make update_deps
  cd cmd/golangci-lint
  go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'"

Fixes #500
@jeanbza
Copy link
Member

jeanbza commented May 13, 2019

I'm still seeing this with golang.org/x/tools v0.0.0-20190114222345-bf090417da8b. Should I open a new bug?

@matloob
Copy link
Contributor

matloob commented Jun 19, 2019

Yes, if you're still seeinig this after golang.org/cl/170342, please open a new bug

@golang golang locked and limited conversation to collaborators Jun 18, 2020
@rsc rsc unassigned matloob Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants