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

panic: runtime error: index out of range #1437

Closed
wallrj opened this issue Dec 7, 2017 · 27 comments
Closed

panic: runtime error: index out of range #1437

wallrj opened this issue Dec 7, 2017 · 27 comments

Comments

@wallrj
Copy link

wallrj commented Dec 7, 2017

Trying to use dep for project containing a single test file that imports Kubernetes.

package navigator_test

import (
	"testing"

	"k8s.io/client-go/kubernetes"
	"k8s.io/kubernetes/test/integration/framework"
)

func TestIntegration(t *testing.T) {
	masterConfig := framework.NewIntegrationTestMasterConfig()
	_, server, closeFn := framework.RunAMaster(masterConfig)

	defer closeFn()
	config := restclient.Config{Host: server.URL}
	client, err := kubernetes.NewForConfig(&config)
	if err != nil {
		t.Fatalf("Error in creating clientset: %v", err)
	}
	t.Log(client)
}

cat Gopkg.toml
[[override]]
  name = "k8s.io/client-go"
  branch = "release-5.0"

[[override]]
  name = "k8s.io/apimachinery"
  branch = "release-1.8"

[[override]]
  name = "k8s.io/api"
  branch = "release-1.8"

[[override]]
  name = "k8s.io/apiserver"
  branch = "release-1.8"

[[override]]
  name = "k8s.io/kubernetes"
  branch = "release-1.8"

[[override]]
  name = "golang.org/x/exp"
  revision = "292a51b8d262487dab23a588950e8052d63d9113"

[[override]]
  name = "github.com/opencontainers/runc"
  version = "v1.0.0-rc4"

I tried to run dep init but it failed.

So I created a Gopkg.toml file, which overrides the specific versions of Kubernetes projects that I want to depend on, and ran dep ensure -v.

It failed a couple more times and I added specific versions of golang.org/x/exp and github.com/opencontainers/runc to the overrides.

This time it got further, but hung at

richard   1813  0.0  0.0  38024 13324 ?        Ss   Dec05   0:12 tmux                                                                                                                            
richard   1852  0.0  0.0  20360  4112 pts/2    Ss   Dec05   0:00  \_ -bash                                                                                                                       
richard   4859  0.8  0.3 563104 54084 pts/2    Sl+  11:50   0:03  |   \_ dep ensure -v                               
richard  19706  0.0  0.0  17016  1120 pts/2    T    11:52   0:00  |       \_ git ls-remote ssh://git@bitbucket.org/ww/goautoneg                                                                  
richard  19707  0.0  0.0  48668  5852 pts/2    T    11:52   0:00  |           \_ ssh git@bitbucket.org git-upload-pack '/ww/goautoneg'

I ran strace on the subprocess:

strace -p 19707                                                                     
strace: Process 19707 attached                                                                                                                                                                   
--- stopped by SIGTTOU ---                                                                                                                                 
^Cstrace: Process 19707 detached          

I ran git ls-remote git://bitbucket.org/ww/goautoneg in another shell and it hung for me too.

I installed mercurial (hg) and then killed the subprocesses.

Now dep makes progress but fails as follows.

dep ensure -v
...
(106) ✗   package github.com/google/cadvisor/accelerators does not exist within project github.com/google/cadvisor
(106)     try github.com/google/cadvisor@v0.19.3.1
(106) ✗   package github.com/google/cadvisor/accelerators does not exist within project github.com/google/cadvisor
(106)     try github.com/google/cadvisor@v0.19.3.2
(106) ✗   package github.com/google/cadvisor/accelerators does not exist within project github.com/google/cadvisor
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/golang/dep/gps.(*solver).findValidVersion(0xc42007ea20, 0xc421871b80, 0xc420ab5600, 0x2a, 0x2a, 0x0, 0xc420ab5600)
        /home/richard/go/src/github.com/golang/dep/gps/solver.go:957 +0x521
github.com/golang/dep/gps.(*solver).createVersionQueue(0xc42007ea20, 0xc420b70900, 0x1a, 0x0, 0x0, 0xc420ab5600, 0x2a, 0x2a, 0x0, 0x0, ...)
        /home/richard/go/src/github.com/golang/dep/gps/solver.go:914 +0x955
github.com/golang/dep/gps.(*solver).solve(0xc42007ea20, 0xbec060, 0xc42001a098, 0x0, 0xc42021fb60, 0xc42021fbc0)
        /home/richard/go/src/github.com/golang/dep/gps/solver.go:517 +0x5b0
github.com/golang/dep/gps.(*solver).Solve(0xc42007ea20, 0xbec060, 0xc42001a098, 0xc47f40, 0xc42001c019, 0x23, 0xc42021f770)
        /home/richard/go/src/github.com/golang/dep/gps/solver.go:457 +0xe4
main.(*ensureCommand).runDefault(0xc42014bd66, 0xc420076ff0, 0xc4200101a0, 0x0, 0x0, 0xc42005f440, 0xbef480, 0xc420063380, 0xc42001c004, 0x38, ...)
        /home/richard/go/src/github.com/golang/dep/cmd/dep/ensure.go:288 +0x168
main.(*ensureCommand).Run(0xc42014bd66, 0xc420076ff0, 0xc4200101a0, 0x0, 0x0, 0x0, 0x0)
        /home/richard/go/src/github.com/golang/dep/cmd/dep/ensure.go:206 +0x4f4
main.(*Config).Run(0xc420062f60, 0xc420062f60)
        /home/richard/go/src/github.com/golang/dep/cmd/dep/main.go:195 +0x1142
main.main()
        /home/richard/go/src/github.com/golang/dep/cmd/dep/main.go:51 +0x1fc

dep version
dep:
 version     : devel
 build date  :
 git hash    :
 go version  : go1.9.1
 go compiler : gc
 platform    : linux/amd64
dep hash-inputs -v
-CONSTRAINTS-
k8s.io/client-go
b-release-5.0
k8s.io/kubernetes
b-release-1.8
-IMPORTS/REQS-
k8s.io/client-go/kubernetes
k8s.io/kubernetes/test/integration/framework
-IGNORES-
-OVERRIDES-
github.com/opencontainers/runc
svc-^1.0.0-rc4
golang.org/x/exp
r-292a51b8d262487dab23a588950e8052d63d9113
k8s.io/api
b-release-1.8
k8s.io/apimachinery
b-release-1.8
k8s.io/apiserver
b-release-1.8
k8s.io/client-go
b-release-5.0
k8s.io/kubernetes
b-release-1.8
-ANALYZER-
dep
1

@wallrj
Copy link
Author

wallrj commented Dec 7, 2017

Seems to be re-producible. I deleted ~/go/pkg/dep and tried again, but got the same panic.

@sdboyer
Copy link
Member

sdboyer commented Dec 7, 2017

hiya, welcome! sorry you're running into this. the k8s migration path is still difficult, unfortunately; we've got several issues open and it's very much on our radar.

the panic is definitely a solver bookkeeping bug, and one i've not seen before. not much more to say about that except "whoops," and i'll have to dig in to address it. (i replicated locally, though the panic ended up occurring on a different project).

the hang when checking on bitbucket but not having hg installed is concerning. that's a bit of a sloppy segment of code, in general - we're basically just probing with git and mercurial to see what vcs type it is - and having it hang in that way when hg isn't installed is really not good. ideally, we could query the bitbucket HTTP API and to figure out the VCS type, rather than relying on that kludgey discovery.

@BenTheElder
Copy link

the hang when checking on bitbucket but not having hg installed is concerning. that's a bit of a sloppy segment of code, in general - we're basically just probing with git and mercurial to see what vcs type it is - and having it hang in that way when hg isn't installed is really not good. ideally, we could query the bitbucket HTTP API and to figure out the VCS type, rather than relying on that kludgey discovery.

I was just hunting through issues before filing one about this, @sdboyer is there an issue tracking this hang? We just ran into this at kubernetes/test-infra#6043 / kubernetes/test-infra#5987, and I remember seeing this before and then forgetting about it after installing hg.

@cblecker
Copy link
Contributor

cblecker commented Dec 20, 2017

heh.. I was just verifying that this is still an issue on HEAD (it is). if you import a mercurial dependency, don't have hg installed and use dep ensure, dep will hang with no output.

if you CTRL+C it, you get the following:

^CSignal received: waiting for 1 ops to complete...
grouped write of manifest, lock and vendor: error while writing out vendor tree: failed to write dep tree: failed to export bitbucket.org/ww/goautoneg: no valid source could be created: 
        failed to set up sources from the following URLs:
https://bitbucket.org/ww/goautoneg
: hg is not installed: 
        failed to set up sources from the following URLs:
ssh://hg@bitbucket.org/ww/goautoneg
: hg is not installed: 
        failed to set up sources from the following URLs:
http://bitbucket.org/ww/goautoneg
: hg is not installed: 
        failed to set up sources from the following URLs:
https://bitbucket.org/ww/goautoneg
: remote repository at https://bitbucket.org/ww/goautoneg does not exist, or is inaccessible: remote: Not Found
fatal: repository 'https://bitbucket.org/ww/goautoneg/' not found
: exit status 128
        failed to set up sources from the following URLs:
ssh://git@bitbucket.org/ww/goautoneg
: remote repository at ssh://git@bitbucket.org/ww/goautoneg does not exist, or is inaccessible: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
: exit status 128
        failed to set up sources from the following URLs:
git://bitbucket.org/ww/goautoneg
: remote repository at git://bitbucket.org/ww/goautoneg does not exist, or is inaccessible: : signal: interrupt
        failed to set up sources from the following URLs:
http://bitbucket.org/ww/goautoneg
: context canceled

@nhooyr
Copy link

nhooyr commented Jan 17, 2018

Getting this same error, just not on dep ensure. Only on dep ensure --update and its not reproducible. Nondeterministic. No idea what the cause is. And I can't provide sources because the project is private :(

@nhooyr
Copy link

nhooyr commented Jan 17, 2018

If someone from the team is available, I would be ok with sharing the private traces/verbose output with them personally for debugging, as long as nothing is posted publicly.

@sdboyer
Copy link
Member

sdboyer commented Jan 17, 2018

@nhooyr you can send them to me on slack.

i hope to have time to look at the panics here, at least, in a couple weeks. still trying to get the next release out the door, first.

@kentquirk
Copy link

kentquirk commented Dec 27, 2018

I just hit this myself using

$ dep version
dep:
 version     : v0.5.0
 build date  : 2018-08-16
 git hash    : 224a564
 go version  : go1.10.3
 go compiler : gc
 platform    : darwin/amd64
 features    : ImportDuringSolve=false

I had a working .toml and .lock file. I changed an upstream dependency and while I wait for my PR to be approved on that one, I wanted to pin the dependency in this project to that particular revision.

I tried this:

$ dep ensure -add github.com/oneiro-ndev/chaincode@981f07a -v
Fetching sources...

Failed to add the dependencies:

  ✗ could not infer project root from dependency path: -v: "-v" is not a valid import path
  ✗ Gopkg.toml already contains rules for github.com/oneiro-ndev/chaincode, cannot specify a version constraint or alternate source

adding dependencies failed

(This, btw, is somewhat misleading -- Gopkg.toml does not contain a rule for chaincode, but Gopkg.lock does.)

So I deleted the .lock file and the vendor directory, added a constraint to the .toml file, and ran dep ensure. It crashed with:

$ dep ensure
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/golang/dep/gps.(*solver).findValidVersion(0xc420336c00, 0xc420690280, 0xc4206e2f00, 0x13, 0x13, 0x1b, 0xc4206e2f00)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/gps/solver.go:945 +0x4b9
github.com/golang/dep/gps.(*solver).createVersionQueue(0xc420336c00, 0xc4202f3020, 0x1a, 0xc4201d92c0, 0x1b, 0xc4206e2f00, 0x13, 0x13, 0x0, 0x0, ...)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/gps/solver.go:902 +0x80d
github.com/golang/dep/gps.(*solver).solve(0xc420336c00, 0x15fc260, 0xc420022270, 0x139a0c3, 0x1505a00, 0xc420428000)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/gps/solver.go:505 +0x5b7
github.com/golang/dep/gps.(*solver).Solve(0xc420336c00, 0x15fc260, 0xc420022270, 0x1878f80, 0xc42002409c, 0x1f, 0xc4203a2660)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/gps/solver.go:440 +0xc8
main.(*ensureCommand).runDefault(0xc4201819f0, 0xc4200c2980, 0xc420139860, 0x0, 0x0, 0xc4200e2120, 0x1600200, 0xc4202cd980, 0xc420024084, 0x37, ...)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/cmd/dep/ensure.go:281 +0x361
main.(*ensureCommand).Run(0xc4201819f0, 0xc4200c2980, 0xc420139860, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/cmd/dep/ensure.go:218 +0x865
main.(*Config).Run(0xc42008efc0, 0x0)
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/cmd/dep/main.go:212 +0xfae
main.main()
	/private/tmp/dep-20180816-36758-1qwnesr/src/github.com/golang/dep/cmd/dep/main.go:84 +0x54d

[Edit] Several hours later I looked again at the .toml file and I had used version = "981f07a" instead of revision =. When I changed it to revision it worked properly.

Maybe the solver is blowing up when looking for version tags that aren't valid?

@EtienneM EtienneM mentioned this issue Feb 13, 2019
@EtienneM
Copy link

EtienneM commented Feb 13, 2019

I am running into the same issue with the latest version of dep:

dep:
 version     : v0.5.0
 build date  : 2018-07-26
 git hash    : 224a564
 go version  : go1.10.3
 go compiler : gc
 platform    : linux/amd64
 features    : ImportDuringSolve=false

It gets really blocking for my project. Does anyone of you succeeded to circumvent this bug?

depensure.log

@nhooyr
Copy link

nhooyr commented Feb 13, 2019

@EtienneM Best you switch to go mod.

@kevinburke
Copy link
Collaborator

I'll see if I can take a look at this tonight

@sdboyer
Copy link
Member

sdboyer commented Feb 13, 2019

it's a tricky bookkeeping error in the solver. I've never been able to reproduce it, so I don't know what conditions cause it. if it can be reproduced, the problem spot should be obvious. (it's almost certainly something in backtracking)

@kevinburke
Copy link
Collaborator

@EtienneM are you able to reproduce this error reliably, or is it sporadic? Do you have a public repository that you can reliably reproduce the issue on?

@EtienneM
Copy link

I reproduce it reliably but sadly it's on a private repo...

@rohithsharmaks
Copy link

I am facing the same issue regularly! Is there anyway I can bypass this error and continue?

@fentas
Copy link

fentas commented May 29, 2019

same here.

➜ dep ensure --add github.com/tidwall/sjson
Fetching sources...

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/golang/dep/gps.(*solver).findValidVersion(0xc0000ea200, 0xc009a61900, 0xc00020d5c0, 0x4, 0x4, 0x0, 0xc00020d5c0)
        /home/user/go/src/github.com/golang/dep/gps/solver.go:945 +0x4cc
github.com/golang/dep/gps.(*solver).backtrack(0xc0000ea200, 0xade8a0, 0xc0000b2060, 0x0, 0x0, 0x0)
        /home/user/go/src/github.com/golang/dep/gps/solver.go:1079 +0xbdf
github.com/golang/dep/gps.(*solver).solve(0xc0000ea200, 0xade8a0, 0xc0000b2060, 0x5, 0xc0003a6158, 0xc0002611b0)
        /home/user/go/src/github.com/golang/dep/gps/solver.go:510 +0x867
github.com/golang/dep/gps.(*solver).Solve(0xc0000ea200, 0xade8a0, 0xc0000b2060, 0xeb1d28, 0xc000028056, 0x20, 0xc0002ec090)
        /home/user/go/src/github.com/golang/dep/gps/solver.go:440 +0x1eb
main.(*ensureCommand).runAdd(0xc0001776a0, 0xc0000e8880, 0xc0000bb5f0, 0x1, 0x1, 0xc0000e3200, 0xae6720, 0xc00007cc60, 0xc000028044, 0x32, ...)
        /home/user/go/src/github.com/golang/dep/cmd/dep/ensure.go:587 +0x9af
main.(*ensureCommand).Run(0xc0001776a0, 0xc0000e8880, 0xc0000bb5f0, 0x1, 0x1, 0x0, 0x0)
        /home/user/go/src/github.com/golang/dep/cmd/dep/ensure.go:214 +0x8c7
main.(*Config).Run(0xc0000b8ea0, 0x0)
        /home/user/go/src/github.com/golang/dep/cmd/dep/main.go:212 +0x1117
main.main()
        /home/user/go/src/github.com/golang/dep/cmd/dep/main.go:84 +0x636

On the second try it was working.

@joshuarubin
Copy link

@kevinburke is dep now officially deprecated?

@kevinburke
Copy link
Collaborator

No, see #2166; we're trying to make decisions about how to prioritize a (very limited) amount of maintainer time and assumed if people were still running into problems they could reopen tickets.

@rohithsharmaks
Copy link

rohithsharmaks commented Jun 12, 2019

After upgrading to dep 0.5.3, we are facing same issue for 'dep ensure -update'. Here is the stack trace

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/golang/dep/gps.(*solver).findValidVersion(0xc0004a6000, 0xc05aff0f00, 0xc000688a20, 0x2, 0x2, 0x0, 0xc000688a20)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/gps/solver.go:945 +0x4cc
github.com/golang/dep/gps.(*solver).backtrack(0xc0004a6000, 0x16e3620, 0xc0000240d0, 0x0, 0x0, 0x0)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/gps/solver.go:1079 +0xbdc
github.com/golang/dep/gps.(*solver).solve(0xc0004a6000, 0x16e3620, 0xc0000240d0, 0x5, 0xc0004e82f8, 0xc00044f5e8)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/gps/solver.go:510 +0x872
github.com/golang/dep/gps.(*solver).Solve(0xc0004a6000, 0x16e3620, 0xc0000240d0, 0x1abf9e0, 0xc0000280c5, 0x27, 0xc00038c180)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/gps/solver.go:440 +0x1eb
main.(*ensureCommand).runUpdate(0xc0000b2006, 0xc0001c4000, 0xc0000a41a0, 0x0, 0x0, 0xc0001ca000, 0x16eb5a0, 0xc0000908a0, 0xc0000280a4, 0x48, ...)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/cmd/dep/ensure.go:356 +0x1c1
main.(*ensureCommand).Run(0xc0000b2006, 0xc0001c4000, 0xc0000a41a0, 0x0, 0x0, 0x0, 0x0)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/cmd/dep/ensure.go:216 +0x755
main.(*Config).Run(0xc0000be060, 0x0)
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/cmd/dep/main.go:212 +0x111c
main.main()
/private/tmp/dep-20190519-54335-gb7gel/src/github.com/golang/dep/cmd/dep/main.go:84 +0x636

How do we resolve this?

@kevinburke
Copy link
Collaborator

Do you have a way for me to reliably reproduce the issue? If I can reproduce it, I can probably put together a fix.

@kevinburke
Copy link
Collaborator

I'm happy to sign whatever NDA's you need.

@rohithsharmaks
Copy link

We are getting this error all the time.. May be I can try this in simple project to reproduce it so that I can share that code to you..

@kevinburke
Copy link
Collaborator

OK, thanks.

@rohithsharmaks
Copy link

Right now I can share the 'dep ensure -update -v' output if needed. Will that help?

@kevinburke
Copy link
Collaborator

A Gopkg.toml with dependencies I can download would probably be better! But that would help. kevin@burke.services

@sdboyer
Copy link
Member

sdboyer commented Jun 12, 2019 via email

@rohithsharmaks
Copy link

I have been in offline discussion with @kevinburke for reproducing steps along with Gopkg.toml file. I will be sharing necessary details if required.

Just update where it fails is

  • Before upgrade to 0.5.3,
    -- dep ensure used to fail
    -- dep ensure -update used to succeed.

  • After upgrade to 0.5.3,
    -- dep ensure succeed.
    -- dep ensure -update fails.

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

No branches or pull requests