Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

dep init: panic: runtime error: slice bounds out of range #171

Closed
eparis opened this issue Jan 26, 2017 · 7 comments · Fixed by #361
Closed

dep init: panic: runtime error: slice bounds out of range #171

eparis opened this issue Jan 26, 2017 · 7 comments · Fixed by #361
Assignees
Labels

Comments

@eparis
Copy link

eparis commented Jan 26, 2017

checkout github.com/kubernetes/kubernetes @ db2dc78e6398ba673e68e94bd17d28a97dd4a902
run godep restore to make GOPATH == what's in vendor
inside kubernetes rm -rf vendor Godeps
inside $GOPATH/src/github.com/chai2010/gettext-go make sure that chai2010/gettext-go#7 has been applied
dep init from version 21f357a

$ dep init
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0x7a3fc0, 0xc420012120)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).unselectLast(0xc420ac4a50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/storage/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:1130 +0x68e
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).backtrack(0xc420ac4a50, 0xc4204ab2a0)
	/storage/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:881 +0x13e
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).solve(0xc420ac4a50, 0x0, 0x0, 0xc421378ff0)
	/storage/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:371 +0x791
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).Solve(0xc420ac4a50, 0x25, 0xc4200100a8, 0x11, 0xc420154ff0)
	/storage/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:317 +0x8e
main.(*initCommand).Run(0x9f41c8, 0xc42000c380, 0x0, 0x0, 0x0, 0x0)
	/storage/gopath/src/github.com/golang/dep/init.go:153 +0x102f
main.main()
	/storage/gopath/src/github.com/golang/dep/main.go:101 +0x68b
@sdboyer
Copy link
Member

sdboyer commented Jan 27, 2017

iiiiinteresting.

github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).unselectLast(0xc420ac4a50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)

This means an internal bookkeeping bug in the solver. ...except that there doesn't appear to be a slice access on that line.

@davecheney
Copy link
Contributor

davecheney commented Jan 27, 2017 via email

@sdboyer
Copy link
Member

sdboyer commented Jan 27, 2017

derp. totally. thanks :)

@davecheney
Copy link
Contributor

davecheney commented Jan 27, 2017 via email

@eparis
Copy link
Author

eparis commented Jan 27, 2017

I put some printf's to dig around a bit. In fact it is popDep not pushDep that was panicing.

 func (s *selection) popDep(id ProjectIdentifier) (dep dependency) {
-       deps := s.deps[id.ProjectRoot]
+       deps, ok := s.deps[id.ProjectRoot]
+       if !ok {
+               fmt.Printf("unable to find s.deps[%v]\n", id)
+               return dependency{}
+       }

Gave me:

unable to find s.deps[{k8s.io/kubernetes }]

@sdboyer
Copy link
Member

sdboyer commented Jan 27, 2017

That also makes more sense than a slice bounds error on an append :) Doesn't change anything about the inlining observation, of course.

I'm pretty sure I see the problem here. likely related to the fix for #116, which allowed project-level cyclic dependencies involving the root project. I'm pretty sure I didn't encounter this because the additional test case I wrote didn't cause the solver to backtrack through such cycles.

k8s @ db2dc78e6398ba673e68e94bd17d28a97dd4a902 does have such a project-level cycle, right? (a k8s package imports a package from a dep, which itself transitively imports some package back in k8s)

If so, this is a relief, because it points away from a "bookkeeping bug" in normal operation of the solving algorithm. That would be a much more concerning correctness issue. Instead, I think the cause here is a basic choice to push the root project into the selected list, but not the deps map, when preparing the algorithm. That's a more basic structural question with an easier fix.

@sdboyer
Copy link
Member

sdboyer commented Mar 4, 2017

This should now be fixed upstream - we'll get it in to dep with the next gps update.

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

Successfully merging a pull request may close this issue.

5 participants