go: cmd/compile: panic on conversion to anonymous interface when 2 versions of library are built
What version of Go are you using (go version
)?
$ go version go version go1.11.4 darwin/amd64
Does this issue reproduce with the latest release?
yes it does
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/Users/denis/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/denis/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/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/nl/54f5x38s4m53mkzzj92zsj340000gn/T/go-build581161643=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Run
git clone https://github.com/golangci/test4.git
go run main.go
and got
panic: interface conversion: *ssa.Call is not interface { ssa.setNum(int) }: missing method setNum
goroutine 1 [running]:
github.com/golangci/test2/ssa.Panics(0x105cde0, 0xc000064020, 0x2)
/Users/denis/go/pkg/mod/github.com/golangci/test2@v0.0.0-20190108121323-b241e05eddb2/ssa/func.go:6 +0x82
main.main()
/Users/denis/go/src/github.com/golangci/test4/main.go:14 +0xa0
exit status 2
What did you expect to see?
No panic with anonymous interface cast.
What did you see instead?
Panic.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 30 (22 by maintainers)
Commits related to this issue
- Workaround crash See https://github.com/golang/go/issues/29612 — committed to golangci/go-tools by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Update megacheck to the latest version Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimiz... — committed to golangci/golangci-lint by jirfag 5 years ago
- Workaround crash See https://github.com/golang/go/issues/29612 — committed to golangci/go-tools by jirfag 5 years ago
- go/ssa: make a setNumable interface Workaround crash on go/ssa in go < 1.13. See https://github.com/golang/go/issues/29612. — committed to golangci/tools by jirfag 5 years ago
- go/ssa: make a setNumable interface Workaround crash on go/ssa in go < 1.13. See https://github.com/golang/go/issues/29612. — committed to golangci/tools by jirfag 5 years ago
- test: add test coverage for type-switch hash collisions This CL expands the test for #29612 to check that type switches also work correctly when type hashes collide. Change-Id: Ia153743e6ea0736c1a33... — committed to golang/go by mdempsky 5 years ago
- go/ssa: make a setNumable interface Workaround crash on go/ssa in go < 1.13. See https://github.com/golang/go/issues/29612. Change-Id: I32687f6ee0baaf223248d5c1631663c73cbbfc65 GitHub-Last-Rev: 6bf2... — committed to golang/tools by jirfag 5 years ago
- [go] Update build instructions for golangci-lint See #10825. Try to match more closely the build process followed upstream: - Force module build mode, which builds the latest stable release (not ma... — committed to syl20bnr/spacemacs by panchoh 5 years ago
Interesting. This has been broken since at least Go 1.1. It works with gccgo.
It does seem like something is very wrong. I’ve been able to minimize your test case to a single module with about half the amount of code, but still involving two packages with very similar types and the same package names.
This weird behavior happens on both 1.11.4 and
go version devel +73fb3c38a6 Mon Jan 7 14:13:33 2019 +0000 linux/amd64
. My best guess without any digging is that either the compiler or the runtime get confused by the very similar types in the very similar pakages, and there’s a conflict or misplacement somewhere.The fact that removing the first ssa package from
main.go
makes the second ssa package work fine tells me that there’s no bug in either of the ssa packages./cc @randall77 @ianlancetaylor @dr2chase for some input