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 in go/types during (*loader).refine #33936

Closed
bcmills opened this issue Aug 29, 2019 · 2 comments
Closed

x/tools/go/packages: panic in go/types during (*loader).refine #33936

bcmills opened this issue Aug 29, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Aug 29, 2019

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

example.com$ gotip version
go version devel +3b92f36d Thu Aug 29 08:57:06 2019 +0000 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
example.com$ gotip env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/bcmills/.cache/go-build"
GOENV="/usr/local/google/home/bcmills/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/tmp.b6FwBbMhR2/_gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/google/home/bcmills/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/bcmills/sdk/gotip/pkg/tool/linux_amd64"
GCCGO="/usr/local/google/home/bcmills/bin/gccgo"
AR="ar"
CC="gcc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/tmp/tmp.b6FwBbMhR2/example.com/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-build142029212=/tmp/go-build -gno-record-gcc-switches"

What did you do?


example.com$ gotip mod init example.com
go: creating new go.mod: module example.com

example.com$ gotip version
go version devel +3b92f36d Thu Aug 29 08:57:06 2019 +0000 linux/amd64

example.com$ gotip get -d golang.org/x/exp/apidiff@ec7cb31e5a562f5e9e31b300128d2f530f55d127
go: finding golang.org ec7cb31e5a562f5e9e31b300128d2f530f55d127
go: finding golang.org/x ec7cb31e5a562f5e9e31b300128d2f530f55d127
go: finding golang.org/x/exp ec7cb31e5a562f5e9e31b300128d2f530f55d127
go: finding golang.org/x/exp/apidiff ec7cb31e5a562f5e9e31b300128d2f530f55d127
go: downloading golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56
go: extracting golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56

example.com$ GOTRACEBACK=all gotip test golang.org/x/exp/apidiff

What did you expect to see?

example.com$ GOTRACEBACK=all gotip test golang.org/x/exp/apidiff
ok      golang.org/x/exp/apidiff        0.431s

(Or, a useful test failure output).

What did you see instead?

A panic, with a large backtrace involving golang.org/x/tools/go/packages and go/types

example.com$ GOTRACEBACK=all gotip test golang.org/x/exp/apidiff
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=0x5cbf3b]

goroutine 11 [running]:
go/types.(*Checker).handleBailout(0xc0001205a0, 0xc000049c90)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/check.go:241 +0x98
panic(0x6d23c0, 0x961580)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/panic.go:679 +0x1b2
go/types.(*StdSizes).Sizeof(0x0, 0x791540, 0x962280, 0x72a153)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/sizes.go:154 +0x1bb
go/types.(*Config).sizeof(0xc000175b80, 0x791540, 0x962280, 0xc00017c001)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/sizes.go:251 +0x51
go/types.representableConst(0x795ac0, 0xc00017c0d8, 0xc0001205a0, 0x962280, 0xc0001a2068, 0x40)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/expr.go:216 +0x9a6
go/types.(*Checker).representable(0xc0001205a0, 0xc0001a2040, 0x962280)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/expr.go:335 +0x68
go/types.(*Checker).convertUntyped(0xc0001205a0, 0xc0001a2040, 0x791540, 0x962280)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/expr.go:517 +0x898
go/types.(*Checker).assignment(0xc0001205a0, 0xc0001a2040, 0x791540, 0x962280, 0x72f02d, 0x14)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/assignments.go:46 +0x14c
go/types.(*Checker).initConst(0xc0001205a0, 0xc000059140, 0xc0001a2040)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/assignments.go:93 +0x25b
go/types.(*Checker).constDecl(0xc0001205a0, 0xc000059140, 0x794a80, 0xc00000dcc0, 0x794580, 0xc00000dce0)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/decl.go:362 +0x11d
go/types.(*Checker).objDecl(0xc0001205a0, 0x799c80, 0xc000059140, 0x0)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/decl.go:201 +0x754
go/types.(*Checker).packageObjects(0xc0001205a0)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/resolver.go:589 +0x38a
go/types.(*Checker).checkFiles(0xc0001205a0, 0xc00000e220, 0x1, 0x1, 0x0, 0x0)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/check.go:255 +0xbb
go/types.(*Checker).Files(...)
        /usr/local/google/home/bcmills/sdk/gotip/src/go/types/check.go:246
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc000118000, 0xc00000d400)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:716 +0x555
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:574 +0x17f
sync.(*Once).doSlow(0xc00000d410, 0xc00003af80)
        /usr/local/google/home/bcmills/sdk/gotip/src/sync/once.go:66 +0xe3
sync.(*Once).Do(...)
        /usr/local/google/home/bcmills/sdk/gotip/src/sync/once.go:57
golang.org/x/tools/go/packages.(*loader).loadRecursive(0xc000118000, 0xc00000d400)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:561 +0x78
golang.org/x/tools/go/packages.(*loader).refine.func2(0xc000118000, 0xc000015790, 0xc00000d400)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:542 +0x35
created by golang.org/x/tools/go/packages.(*loader).refine
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:541 +0x73c

goroutine 1 [chan receive]:
testing.(*T).Run(0xc000100300, 0x72be57, 0xb, 0x73bae8, 0x482bd6)
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:961 +0x377
testing.runTests.func1(0xc000100200)
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:1202 +0x78
testing.tRunner(0xc000100200, 0xc000075dc0)
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:909 +0xc9
testing.runTests(0xc00000c180, 0x962700, 0x2, 0x2, 0x0)
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:1200 +0x2a7
testing.(*M).Run(0xc0000fe180, 0x0)
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:1117 +0x176
main.main()
        _testmain.go:46 +0x135

goroutine 6 [semacquire]:
sync.runtime_Semacquire(0xc000015798)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/sema.go:56 +0x42
sync.(*WaitGroup).Wait(0xc000015790)
        /usr/local/google/home/bcmills/sdk/gotip/src/sync/waitgroup.go:130 +0x64
golang.org/x/tools/go/packages.(*loader).refine(0xc000118000, 0xc000076a80, 0x1, 0x4, 0xc00000d240, 0x1, 0x4, 0xc000082ca8, 0x40c768, 0x10, ...)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:546 +0x767
golang.org/x/tools/go/packages.Load(0xc000082d58, 0xc000114600, 0x1, 0x1, 0x2d, 0xc000116800, 0x39, 0x80, 0xc000082d38)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/tools@v0.0.0-20190312151545-0bb0c0a6e846/go/packages/packages.go:178 +0xf0
golang.org/x/exp/apidiff.load(0x72bec5, 0xb, 0xc000016300, 0x1d, 0x4c, 0x80, 0xc000104400)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/apidiff/apidiff_test.go:124 +0x109
golang.org/x/exp/apidiff.TestChanges(0xc000100300)
        /tmp/tmp.b6FwBbMhR2/_gopath/pkg/mod/golang.org/x/exp@v0.0.0-20190731235908-ec7cb31e5a56/apidiff/apidiff_test.go:29 +0x2a8
testing.tRunner(0xc000100300, 0x73bae8)
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
        /usr/local/google/home/bcmills/sdk/gotip/src/testing/testing.go:960 +0x350
FAIL    golang.org/x/exp/apidiff        0.144s
FAIL

CC @matloob @ianthehat @jba @griesemer

@gopherbot gopherbot added this to the Unreleased milestone Aug 29, 2019
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 29, 2019
@bcmills
Copy link
Contributor Author

bcmills commented Aug 29, 2019

I'm not sure whether the bug here is in go/types or in its particular use in go/packages.

@bcmills
Copy link
Contributor Author

bcmills commented Aug 29, 2019

Hmm, looks like the problem may have been an old x/tools dependency in x/exp/go.mod. After updating a few versions of things it no longer reproduces for me.

@bcmills bcmills closed this as completed Aug 29, 2019
@golang golang locked and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants