Skip to content
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.

panic: New already declared #9

Closed
broady opened this issue Jul 13, 2016 · 9 comments
Closed

panic: New already declared #9

broady opened this issue Jul 13, 2016 · 9 comments
Labels

Comments

@broady
Copy link

broady commented Jul 13, 2016

Not sure why it's happening, but I just saw this. I'll try to look into it at some point. Posting it here in case someone else can reproduce.

$ staticcheck  .
panic: New already declared [recovered]
    panic: New already declared

goroutine 1 [running]:
panic(0x25e200, 0xc4200c4490)
    /Users/cbro/go/src/runtime/panic.go:500 +0x1a1
go/types.(*Checker).handleBailout(0xc420176000, 0xc4202853a8)
    /Users/cbro/go/src/go/types/check.go:213 +0xae
panic(0x25e200, 0xc4200c4490)
    /Users/cbro/go/src/runtime/panic.go:458 +0x243
golang.org/x/tools/go/gcimporter15.(*importer).declare(0xc4201761c0, 0x3e3f20, 0xc4200c6230)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/bimport.go:184 +0x16b
golang.org/x/tools/go/gcimporter15.(*importer).obj(0xc4201761c0, 0xfffffffffffffffb)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/bimport.go:212 +0x4c2
golang.org/x/tools/go/gcimporter15.BImportData(0xc42046c480, 0xc420174570, 0xc4203db000, 0xb79, 0xe00, 0xc4201667a1, 0x6, 0x6, 0xc420001508, 0xd0, ...)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/bimport.go:97 +0x3e8
golang.org/x/tools/go/gcimporter15.Import(0xc420174570, 0xc4201667a1, 0x6, 0xc42010a4d0, 0x62, 0xc4203d6cd0, 0x0, 0x0)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/gcimporter.go:178 +0x5da
honnef.co/go/lint.importer.ImportFrom(0x2dd4d0, 0xc420174570, 0xc4201667a1, 0x6, 0xc42010a4d0, 0x62, 0x0, 0x28b740, 0x3e0501, 0x4d40f0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint16.go:16 +0x58
honnef.co/go/lint.(*importer).ImportFrom(0xc420167840, 0xc4201667a1, 0x6, 0xc42010a4d0, 0x62, 0x0, 0x1, 0x2, 0x0)
    <autogenerated>:5 +0x97
go/types.(*Checker).collectObjects(0xc420176000)
    /Users/cbro/go/src/go/types/resolver.go:191 +0x81d
go/types.(*Checker).checkFiles(0xc420176000, 0xc4201707c0, 0x8, 0x8, 0x0, 0x0)
    /Users/cbro/go/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc420176000, 0xc4201707c0, 0x8, 0x8, 0xc420174660, 0xc4200fb510)
    /Users/cbro/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc420170780, 0xc42013e8d7, 0x9, 0xc420013640, 0xc4201707c0, 0x8, 0x8, 0xc42016b2c0, 0xc420172be0, 0x18, ...)
    /Users/cbro/go/src/go/types/api.go:344 +0x19f
honnef.co/go/lint.(*Pkg).typeCheck(0xc420013680, 0x460000000004a7a0, 0x8)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint.go:256 +0x403
honnef.co/go/lint.(*Pkg).lint(0xc420013680, 0x3f6ba0, 0x12, 0x12, 0xc420163a01, 0x4, 0xc420133a80)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint.go:127 +0x40
honnef.co/go/lint.(*Linter).LintFiles(0xc420285870, 0xc4202858c0, 0xc4200fb870, 0xc4200fb898, 0x76c, 0x0, 0x0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint.go:109 +0x708
honnef.co/go/lint/lintutil.(*runner).lintFiles(0xc420285e40, 0xc42001e180, 0x8, 0xc)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:114 +0x29a
honnef.co/go/lint/lintutil.(*runner).lintImportedPackage(0xc420285e40, 0xc420073c00, 0x0, 0x0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:162 +0x52a
honnef.co/go/lint/lintutil.(*runner).lintPackage(0xc420285e40, 0xc4200acbeb, 0x47)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:134 +0xf2
honnef.co/go/lint/lintutil.ProcessArgs(0x2b9124, 0xb, 0x3f6ba0, 0x12, 0x12, 0xc420010830, 0x1, 0x1)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:90 +0x325
main.main()
    /Users/cbro/src/gocode/src/honnef.co/go/staticcheck/cmd/staticcheck/staticcheck.go:22 +0x259
Exit code 2
$ go version
go version devel +ed9362f Tue Jun 28 12:28:05 2016 +0000 darwin/amd64
@broady
Copy link
Author

broady commented Jul 13, 2016

... and at tip:

$ go version
go version devel +29ed5da Wed Jul 13 21:18:19 2016 +0000 darwin/amd64

$ staticcheck
panic: UTC already declared [recovered]
    panic: UTC already declared

goroutine 1 [running]:
panic(0x25e9c0, 0xc420340540)
    /Users/cbro/go/src/runtime/panic.go:500 +0x1a1
go/types.(*Checker).handleBailout(0xc420176000, 0xc4200f73b8)
    /Users/cbro/go/src/go/types/check.go:213 +0xae
panic(0x25e9c0, 0xc420340540)
    /Users/cbro/go/src/runtime/panic.go:458 +0x243
golang.org/x/tools/go/gcimporter15.(*importer).declare(0xc420176540, 0x3e4440, 0xc420342be0)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/bimport.go:184 +0x16b
golang.org/x/tools/go/gcimporter15.(*importer).obj(0xc420176540, 0xfffffffffffffffc)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/bimport.go:204 +0x1bd
golang.org/x/tools/go/gcimporter15.BImportData(0xc4200121c0, 0xc420174570, 0xc4202f4000, 0x39d7f, 0x3fe00, 0xc42000b62b, 0x4, 0x4, 0x8524, 0x294260, ...)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/bimport.go:97 +0x3e8
golang.org/x/tools/go/gcimporter15.Import(0xc420174570, 0xc42000b62b, 0x4, 0xc42010a310, 0x62, 0xc4203e5540, 0x0, 0x0)
    /Users/cbro/src/gocode/src/golang.org/x/tools/go/gcimporter15/gcimporter.go:178 +0x5da
honnef.co/go/lint.importer.ImportFrom(0x2ddc58, 0xc420174570, 0xc42000b62b, 0x4, 0xc42010a310, 0x62, 0x0, 0x28be40, 0x7d127301, 0x4d50f0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint16.go:16 +0x58
honnef.co/go/lint.(*importer).ImportFrom(0xc420167840, 0xc42000b62b, 0x4, 0xc42010a310, 0x62, 0x0, 0xc4202a7b30, 0x0, 0x0)
    <autogenerated>:5 +0x97
go/types.(*Checker).collectObjects(0xc420176000)
    /Users/cbro/go/src/go/types/resolver.go:191 +0x81d
go/types.(*Checker).checkFiles(0xc420176000, 0xc4201707c0, 0x8, 0x8, 0x0, 0x0)
    /Users/cbro/go/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc420176000, 0xc4201707c0, 0x8, 0x8, 0xc420174660, 0xc4200fb510)
    /Users/cbro/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc420170780, 0xc42013eb70, 0x9, 0xc420013640, 0xc4201707c0, 0x8, 0x8, 0xc4201692c0, 0xc420172ba0, 0x18, ...)
    /Users/cbro/go/src/go/types/api.go:344 +0x19f
honnef.co/go/lint.(*Pkg).typeCheck(0xc420013680, 0x7a0000000004a7f0, 0x8)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint.go:256 +0x403
honnef.co/go/lint.(*Pkg).lint(0xc420013680, 0x3f7740, 0x12, 0x12, 0xc42015ae01, 0x4, 0xc42012fa80)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint.go:127 +0x40
honnef.co/go/lint.(*Linter).LintFiles(0xc4200f7880, 0xc4200f78d0, 0xc4200fb870, 0xc4200fb898, 0x76c, 0x0, 0x0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lint.go:109 +0x708
honnef.co/go/lint/lintutil.(*runner).lintFiles(0xc4200f7e50, 0xc42001e180, 0x8, 0xc)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:114 +0x29a
honnef.co/go/lint/lintutil.(*runner).lintImportedPackage(0xc4200f7e50, 0xc420073c00, 0x0, 0x0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:162 +0x52a
honnef.co/go/lint/lintutil.(*runner).lintPackage(0xc4200f7e50, 0xc4200acbeb, 0x47)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:134 +0xf2
honnef.co/go/lint/lintutil.ProcessArgs(0x2b9848, 0xb, 0x3f7740, 0x12, 0x12, 0x0, 0x0, 0x0)
    /Users/cbro/src/gocode/src/honnef.co/go/lint/lintutil/util.go:90 +0x325
main.main()
    /Users/cbro/src/gocode/src/honnef.co/go/staticcheck/cmd/staticcheck/staticcheck.go:22 +0x259

@dominikh
Copy link
Owner

Does this happen with all packages you're trying to check, or only specific ones?

@broady
Copy link
Author

broady commented Jul 13, 2016

Looks like it's only github.com/GoogleCloudPlatform/golang-samples/getting-started/bookshelf

@dominikh
Copy link
Owner

I'm wondering if the gcimporter15 packages has several issues. When running a staticcheck that's compiled with tip on the fmt package, I get

panic: runtime error: index out of range [recovered]
    panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x6741c0, 0xc420010180)
    /home/dominikh/go/src/runtime/panic.go:500 +0x1a1
go/types.(*Checker).handleBailout(0xc4202aa000, 0xc42019b3b8)
    /home/dominikh/go/src/go/types/check.go:213 +0xae
panic(0x6741c0, 0xc420010180)
    /home/dominikh/go/src/runtime/panic.go:458 +0x243
golang.org/x/tools/go/gcimporter15.(*importer).string(0xc4200ba0c0, 0x37, 0x0)
    /home/dominikh/prj/src/golang.org/x/tools/go/gcimporter15/bimport.go:632 +0x2bb
golang.org/x/tools/go/gcimporter15.BImportData(0xc4202a36e0, 0xc4202ce000, 0x14ffa, 0x1fe00, 0xc4200112f1, 0x5, 0x0, 0x5, 0x7fd5c892a0f0, 0x4b69e0)
    /home/dominikh/prj/src/golang.org/x/tools/go/gcimporter15/bimport.go:70 +0x190
golang.org/x/tools/go/gcimporter15.Import(0xc4202a36e0, 0xc4200112f1, 0x5, 0xc42013a630, 0x19, 0x0, 0x0, 0x0)
    /home/dominikh/prj/src/golang.org/x/tools/go/gcimporter15/gcimporter.go:177 +0x557
honnef.co/go/lint.importer.ImportFrom(0x6ddc48, 0xc4202a36e0, 0xc4200112f1, 0x5, 0xc42013a630, 0x19, 0x0, 0x68bc60, 0x7e0501, 0x7fd5c892a0f0)
    /home/dominikh/prj/src/honnef.co/go/lint/lint16.go:16 +0x58
honnef.co/go/lint.(*importer).ImportFrom(0xc42029f400, 0xc4200112f1, 0x5, 0xc42013a630, 0x19, 0x0, 0x0, 0x1, 0xc4202a8380)
    <autogenerated>:5 +0x97
go/types.(*Checker).collectObjects(0xc4202aa000)
    /home/dominikh/go/src/go/types/resolver.go:191 +0x81d
go/types.(*Checker).checkFiles(0xc4202aa000, 0xc4202a7060, 0x3, 0x4, 0x0, 0x0)
    /home/dominikh/go/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc4202aa000, 0xc4202a7060, 0x3, 0x4, 0xc4202a37d0, 0xc4202a7060)
    /home/dominikh/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc4202a8400, 0xc42029e210, 0x8, 0xc4200154c0, 0xc4202a7060, 0x3, 0x4, 0xc4202a0870, 0xc4202a7040, 0x18, ...)
    /home/dominikh/go/src/go/types/api.go:344 +0x19f
honnef.co/go/lint.(*Pkg).typeCheck(0xc420015500, 0x8c0000000044a800, 0x8)
    /home/dominikh/prj/src/honnef.co/go/lint/lint.go:256 +0x403
honnef.co/go/lint.(*Pkg).lint(0xc420015500, 0x7f77e0, 0x12, 0x12, 0xc42029a801, 0x4, 0xc420259680)
    /home/dominikh/prj/src/honnef.co/go/lint/lint.go:127 +0x40
honnef.co/go/lint.(*Linter).LintFiles(0xc42019b880, 0xc42019b8d0, 0xc420049880, 0xc4200498a8, 0xa6c, 0x0, 0x0)
    /home/dominikh/prj/src/honnef.co/go/lint/lint.go:109 +0x708
honnef.co/go/lint/lintutil.(*runner).lintFiles(0xc42019be50, 0xc420015440, 0x3, 0x4)
    /home/dominikh/prj/src/honnef.co/go/lint/lintutil/util.go:114 +0x29a
honnef.co/go/lint/lintutil.(*runner).lintImportedPackage(0xc42019be50, 0xc42007bc00, 0x0, 0x0)
    /home/dominikh/prj/src/honnef.co/go/lint/lintutil/util.go:161 +0x4f8
honnef.co/go/lint/lintutil.(*runner).lintPackage(0xc42019be50, 0x7ffc3e6c8e44, 0x3)
    /home/dominikh/prj/src/honnef.co/go/lint/lintutil/util.go:134 +0xf2
honnef.co/go/lint/lintutil.ProcessArgs(0x6b966b, 0xb, 0x7f77e0, 0x12, 0x12, 0xc4200108d0, 0x1, 0x1)
    /home/dominikh/prj/src/honnef.co/go/lint/lintutil/util.go:90 +0x325
main.main()
    /home/dominikh/prj/src/honnef.co/go/staticcheck/cmd/staticcheck/staticcheck.go:22 +0x259

@dominikh
Copy link
Owner

Okay, my issue was fixed by updating golang.org/x/tools/go/gcimporter15. Does the same help with your issue?

@broady broady closed this as completed Jul 13, 2016
@broady broady reopened this Jul 13, 2016
@dominikh
Copy link
Owner

Are you sure? Because I still seem to be able to reproduce it for that particular package

@broady
Copy link
Author

broady commented Jul 13, 2016

Still doesn't work. I thought it did, but I was in the wrong directory. I still reproduce it.

(sorry for the sneaky edit)

@dominikh
Copy link
Owner

This seems to be golang/go#15517

@dominikh
Copy link
Owner

I'll close this issue. One bug is the one I mentioned earlier. The fix for that hasn't been backported to gcimporter15 yet; I filed an issue for that.

Another bug can occur if you have object files in $GOPATH/pkg that were compiled with an older, buggy version of Go tip. That bug manifests itself in an almost identical fashion to this issue. In that case, you'll want to wipe pkg or rebuild your packages respectively.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants