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

go/types: panic: unreachable #17716

Closed
kevinburke opened this issue Nov 1, 2016 · 13 comments
Closed

go/types: panic: unreachable #17716

kevinburke opened this issue Nov 1, 2016 · 13 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@kevinburke
Copy link
Contributor

kevinburke commented Nov 1, 2016

Please answer these questions before submitting your issue. Thanks!

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

go version devel +2d4d22a Mon Oct 31 23:53:50 2016 +0000 linux/amd64

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

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/travis/gopath"
GORACE=""
GOROOT="/home/travis/.gimme/versions/go"
GOTOOLDIR="/home/travis/.gimme/versions/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build395845056=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

I ran go vet on my API client. A failing build can be found here: https://travis-ci.org/kevinburke/twilio-go/jobs/172067772

What did you expect to see?

I expected to see no output and a 0 return code, or a list of errors in the program.

What did you see instead?

A panic followed by a stack trace:

go vet ./...
panic: unreachable [recovered]
	panic: unreachable
goroutine 1 [running]:
panic(0x66ca60, 0xc42086a160)
	/home/travis/.gimme/versions/go/src/runtime/panic.go:531 +0x1cf
go/types.(*Checker).handleBailout(0xc4200a41c0, 0xc420417958)
	/home/travis/.gimme/versions/go/src/go/types/check.go:213 +0xa4
panic(0x66ca60, 0xc42086a160)
	/home/travis/.gimme/versions/go/src/runtime/panic.go:489 +0x2d3
go/types.unreachable()
	/home/travis/.gimme/versions/go/src/go/types/errors.go:23 +0x64
go/types.(*Checker).selector(0xc4200a41c0, 0xc420440500, 0xc4201d9620)
	/home/travis/.gimme/versions/go/src/go/types/call.go:321 +0x152e
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7e0240, 0xc4201d9620, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4203f4048)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:247 +0xad2
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7e0240, 0xc4201d9620, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).typ(0xc4200a41c0, 0x7e0240, 0xc4201d9620, 0x0, 0x1)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:153 +0x63
go/types.(*Checker).collectParams(0xc4200a41c0, 0xc420953270, 0xc4201c33b0, 0xc420953201, 0xc4203f4048, 0x1, 0x1, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:421 +0x150
go/types.(*Checker).funcType(0xc4200a41c0, 0xc42094ce10, 0xc4201c3380, 0xc4201d99a0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:162 +0x1f6
go/types.(*Checker).funcDecl(0xc4200a41c0, 0xc4200174f0, 0xc420017540)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:322 +0xe8
go/types.(*Checker).objDecl(0xc4200a41c0, 0x7e2360, 0xc4200174f0, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:87 +0x403
go/types.(*Checker).addMethodDecls(0xc4200a41c0, 0xc420016af0)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:305 +0x587
go/types.(*Checker).typeDecl(0xc4200a41c0, 0xc420016af0, 0x7e0340, 0xc4201d8a40, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:254 +0x1bd
go/types.(*Checker).objDecl(0xc4200a41c0, 0x7e25e0, 0xc420016af0, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:84 +0x46d
go/types.(*Checker).ident(0xc4200a41c0, 0xc420440440, 0xc4201fda40, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:36 +0x153
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7dff00, 0xc4201fda40, 0x0, 0x0, 0x0, 0x0, 0xc420036400, 0x2b51d63d74b0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:230 +0x643
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7dff00, 0xc4201fda40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).typ(0xc4200a41c0, 0x7dff00, 0xc4201fda40, 0x6928e0, 0xc4204b4f48)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:153 +0x63
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7e0300, 0xc4201fda60, 0x0, 0xc4203f4008, 0x1, 0x1, 0xc420416a30, 0xc420416aa0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:289 +0x9df
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7e0300, 0xc4201fda60, 0x0, 0xc4203f4008, 0x1, 0x1, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).structType(0xc4200a41c0, 0xc42094cc90, 0xc4201fde40, 0xc4203f4008, 0x1, 0x1)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:661 +0x1e3
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7e0340, 0xc4201fde40, 0xc42094cc60, 0xc4203f4008, 0x1, 0x1, 0xc420024801, 0xc42094cc60)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:283 +0x11c8
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7e0340, 0xc4201fde40, 0xc42094cc60, 0xc4203f4008, 0x1, 0x1, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).typeDecl(0xc4200a41c0, 0xc420402690, 0x7e0340, 0xc4201fde40, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:232 +0x162
go/types.(*Checker).objDecl(0xc4200a41c0, 0x7e25e0, 0xc420402690, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:84 +0x46d
go/types.(*Checker).ident(0xc4200a41c0, 0xc420440180, 0xc4201c69e0, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:36 +0x153
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7dff00, 0xc4201c69e0, 0x0, 0x0, 0x0, 0x0, 0xc420036400, 0x2b51d63d74b0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:230 +0x643
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7dff00, 0xc4201c69e0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).typ(0xc4200a41c0, 0x7dff00, 0xc4201c69e0, 0x6928e0, 0xc4201c6960)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:153 +0x63
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7e0300, 0xc4201c6a00, 0x0, 0xc4204178a0, 0x1, 0x8, 0x0, 0xc4204174a0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:289 +0x9df
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7e0300, 0xc4201c6a00, 0x0, 0xc4204178a0, 0x1, 0x8, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).structType(0xc4200a41c0, 0xc42094cc30, 0xc4201c6a20, 0xc4204178a0, 0x1, 0x8)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:661 +0x1e3
go/types.(*Checker).typExprInternal(0xc4200a41c0, 0x7e0340, 0xc4201c6a20, 0xc42094cc00, 0xc4204178a0, 0x1, 0x8, 0xc420024701, 0xc42094cc00)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:283 +0x11c8
go/types.(*Checker).typExpr(0xc4200a41c0, 0x7e0340, 0xc4201c6a20, 0xc42094cc00, 0xc4204178a0, 0x1, 0x8, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/typexpr.go:145 +0x95
go/types.(*Checker).typeDecl(0xc4200a41c0, 0xc420222b40, 0x7e0340, 0xc4201c6a20, 0x0, 0xc4204178a0, 0x0, 0x8)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:232 +0x162
go/types.(*Checker).objDecl(0xc4200a41c0, 0x7e25e0, 0xc420222b40, 0x0, 0xc4204178a0, 0x0, 0x8)
	/home/travis/.gimme/versions/go/src/go/types/decl.go:84 +0x46d
go/types.(*Checker).packageObjects(0xc4200a41c0, 0xc42021a600, 0x11c, 0x130)
	/home/travis/.gimme/versions/go/src/go/types/resolver.go:428 +0x133
go/types.(*Checker).checkFiles(0xc4200a41c0, 0xc4202f2e00, 0x21, 0x40, 0x0, 0x0)
	/home/travis/.gimme/versions/go/src/go/types/check.go:227 +0xe4
go/types.(*Checker).Files(0xc4200a41c0, 0xc4202f2e00, 0x21, 0x40, 0xc4202f9dd0, 0xc4200b99d0)
	/home/travis/.gimme/versions/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc420301740, 0xc4200138a0, 0x6, 0xc420019840, 0xc4202f2e00, 0x21, 0x40, 0xc4202fcbe0, 0xc4200b9a50, 0xc4200b9a60, ...)
	/home/travis/.gimme/versions/go/src/go/types/api.go:344 +0x180
main.(*Package).check(0xc42001baa0, 0xc420019840, 0xc4202f2e00, 0x21, 0x40, 0xc4202f3000, 0x20)
	/home/travis/.gimme/versions/go/src/cmd/vet/types.go:76 +0x34f
main.doPackage(0x6c1614, 0x1, 0xc42000a250, 0x21, 0x23, 0x0, 0xffffffffffffffff)
	/home/travis/.gimme/versions/go/src/cmd/vet/main.go:339 +0x8e6
main.main()
	/home/travis/.gimme/versions/go/src/cmd/vet/main.go:247 +0x382
exit status 2
make: *** [vet] Error 1

I can reliably reproduce this error in Travis CI's build environment, but I have been unable to reproduce this problem otherwise. Running go vet ./... with the same library commit and Go commit SHA on darwin/amd64 runs just fine; I'm only able to reproduce the problem in Travis CI.

I also tried deleting all of the other code in the library, so only the token directory existed. If only the token directory exists, go vet passes.

To reproduce, check out the master branch on this project: https://github.com/kevinburke/twilio-go/ (specifically this commit: kevinburke/twilio-go@76f2274). Enable Travis-CI builds on your fork, then push a new commit. It should fail with the panic pasted above, after about 2 minutes. Note Travis builds tip against tip, the Go commit being built may change from under you if more commits are pushed to golang/go master.

I run a Ubuntu 16 server and tried to build Go tip on that machine to set up a reduced test case, but I'm getting an error when compiling Go tip. Someone on Gophers slack suggested it may be a memory problem; that machine has 850MB of free RAM. I can open a separate ticket for that issue if you'd like.

I tried searching for this stack trace elsewhere in Go issues and couldn't find anything, my apologies if this is a duplicate.

@quentinmit quentinmit changed the title go vet: panics with "unreachable" on linux/amd64 go/types: panic: unreachable Nov 1, 2016
@quentinmit quentinmit added this to the Go1.8Maybe milestone Nov 1, 2016
@quentinmit quentinmit added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 1, 2016
@quentinmit
Copy link
Contributor

/cc @griesemer

@griesemer griesemer self-assigned this Nov 1, 2016
@griesemer
Copy link
Contributor

I suspect this is due to aliases. @kevinburke do you know by any chance if the code you're processing imports a package that exports aliases?

@griesemer griesemer modified the milestones: Go1.8, Go1.8Maybe Nov 1, 2016
@kevinburke
Copy link
Contributor Author

It's possible, but I'd be really surprised. Here is the import list: https://godoc.org/github.com/kevinburke/twilio-go?imports

I can vendor/narrow each of those to a specific commit if you'd like.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/32480 mentions this issue.

@kevinburke
Copy link
Contributor Author

Oh, interesting. I committed all code to a vendor directory with godep:

kevinburke/twilio-go@67ccb76

That built here: https://travis-ci.org/kevinburke/twilio-go/jobs/172343569

And produced a more readable "unreachable" error message:

go vet ./...
vendor/github.com/dgrijalva/jwt-go/errors.go:54: unreachable code
exit status 1

That code is here: https://github.com/kevinburke/twilio-go/blob/alias/vendor/github.com/dgrijalva/jwt-go/errors.go#L45-L55

// Validation error is an error type
func (e ValidationError) Error() string {
    if e.Inner != nil {
        return e.Inner.Error()
    } else if e.text != "" {
        return e.text
    } else {
        return "token is invalid"
    }
    return e.Inner.Error()
}

gopherbot pushed a commit that referenced this issue Nov 1, 2016
This should never be called but should help identify causes of
unexpected panics such as in issue #17716.

Change-Id: Id6ad0cef1088a41bfcc69110a93484a7e39c4128
Reviewed-on: https://go-review.googlesource.com/32480
Run-TryBot: Robert Griesemer <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
@kevinburke
Copy link
Contributor Author

However, I think there's a little more mystery because this commit: https://travis-ci.org/kevinburke/twilio-go/jobs/172191935 doesn't include that library and was still panicking.

@kevinburke
Copy link
Contributor Author

I also grepped the vendor directory for the symbol => and this was all that turned up.

 $ ag '\=\>'
vendor/github.com/golang/protobuf/proto/properties.go
862:    protoFiles = make(map[string][]byte) // file name => fileDescriptor

vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
123:    "ipproto" => "net.inet",
124:    "net.inet.ipproto" => "net.inet",
125:    "net.inet6.ipv6proto" => "net.inet6",
126:    "net.inet6.ipv6" => "net.inet6.ip6",
127:    "net.inet.icmpv6" => "net.inet6.icmp6",
128:    "net.inet6.divert6" => "net.inet6.divert",
129:    "net.inet6.tcp6" => "net.inet.tcp",
130:    "net.inet6.udp6" => "net.inet.udp",
131:    "mpls" => "net.mpls",
132:    "swpenc" => "vm.swapencrypt"
137:    "net.inet.ip.ifq" => "net.ifq",
138:    "net.inet.pfsync" => "net.pfsync",
139:    "net.mpls.ifq" => "net.ifq"

@griesemer
Copy link
Contributor

@kevinburke Thanks, that's useful. I also just committed to tip a new version of the compiler that should print out a bit more than just "unreachable". Could you try to see what you get if you run with the latest tip (and you're original run that caused the problem). Thanks.

@kevinburke
Copy link
Contributor Author

kevinburke commented Nov 1, 2016

Ah, here:

unexpected object alias golang.org/x/net/context.Context (string)

https://travis-ci.org/kevinburke/twilio-go/jobs/172191935#L169

@griesemer
Copy link
Contributor

@kevinburke Great, thanks! This should be all I need.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/32534 mentions this issue.

@kevinburke
Copy link
Contributor Author

Thanks - if this is a result of me doing something weird in my codebase, would love to know :)

@griesemer
Copy link
Contributor

@kevinburke No, it's the result of me doing something weird in my codebase...

I missed a couple of places where I need to handle imported aliases in go/types. The uploaded CL might fix your problem, but I've just found another place that needs the same fix. Writing some tests for this CL and that should hopefully address is.

@golang golang locked and limited conversation to collaborators Nov 1, 2017
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

4 participants