sdboyer / gps

your dependencies have arrived
MIT License
270 stars 24 forks source link

Panic when running example.go against already processed repo #169

Closed krisnova closed 7 years ago

krisnova commented 7 years ago

Recieving this panic message when trying to run a gps example.go binary against an already processed repository. Looks like removing the .repocache directory solves the problem.

panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb0 pc=0x13249c9]

goroutine 1 [running]:
github.com/sdboyer/gps.(*SourceMgr).Release(0x0)
    /go/src/github.com/sdboyer/gps/source_manager.go:282 +0x29
panic(0x13a3040, 0x15d2e20)
    /usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/sdboyer/gps.(*SourceMgr).DeduceProjectRoot(0x0, 0xc4203ea9c1, 0x1d, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/sdboyer/gps/source_manager.go:493 +0x58
github.com/sdboyer/gps.(*bridge).DeduceProjectRoot(0xc420246500, 0xc4203ea9c1, 0x1d, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/sdboyer/gps/bridge.go:315 +0x79
github.com/sdboyer/gps.(*solver).intersectConstraintsWithImports(0xc4201d8000, 0x15f9440, 0x0, 0x0, 0xc420260000, 0x84, 0xb7, 0xc4201f3e60, 0xc4201f3f20, 0xc4201f3fb0, ...)
    /go/src/github.com/sdboyer/gps/solver.go:583 +0x71d
github.com/sdboyer/gps.(*solver).selectRoot(0xc4201d8000, 0xc4201f3e60, 0xc4201f3f20)
    /go/src/github.com/sdboyer/gps/solver.go:463 +0x2e1
github.com/sdboyer/gps.(*solver).Solve(0xc4201d8000, 0x1a, 0xc42000c0a4, 0x1a, 0xc420140a80)
    /go/src/github.com/sdboyer/gps/solver.go:312 +0x6a
main.main()
    /go/src/github.com/sdboyer/gps/example.go:46 +0x35d
/go/src/github.com/sdboyer/gps

Could we get a check in place so at least we aren't seg faulting when this happens?

sdboyer commented 7 years ago

That is bizarre. That that line would produce an mem address or nil pointer deref...wat?

You're on the latest gps master, right?

krisnova commented 7 years ago

Latest GPS (less my PR your just merged)

kris-nova:gps kris$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
kris-nova:gps kris$ git pull origin master
From github.com:kris-nova/gps
 * branch            master     -> FETCH_HEAD
Already up-to-date.
kris-nova:gps kris$ git rev-parse HEAD
2fe10c61f5e68b06b1d2cf6aa7f9a08fab92f94b
kris-nova:gps kris$ go build -o gps example.go && chmod +x gps && mv gps ~/Workspace/kops && cd ~/Workspace/kops/ && ./gps
panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb0 pc=0x1324c39]

goroutine 1 [running]:
github.com/sdboyer/gps.(*SourceMgr).Release(0x0)
    /go/src/github.com/sdboyer/gps/source_manager.go:282 +0x29
panic(0x13a2e20, 0x15d2e20)
    /usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/sdboyer/gps.(*SourceMgr).DeduceProjectRoot(0x0, 0xc42040fb81, 0x1d, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/sdboyer/gps/source_manager.go:493 +0x58
github.com/sdboyer/gps.(*bridge).DeduceProjectRoot(0xc420248540, 0xc42040fb81, 0x1d, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/sdboyer/gps/bridge.go:315 +0x79
github.com/sdboyer/gps.(*solver).intersectConstraintsWithImports(0xc4203ae000, 0x15f9440, 0x0, 0x0, 0xc420350000, 0x84, 0xb7, 0xc4201f3e00, 0xc4201f3ec0, 0xc4201f3ef0, ...)
    /go/src/github.com/sdboyer/gps/solver.go:583 +0x71d
github.com/sdboyer/gps.(*solver).selectRoot(0xc4203ae000, 0xc4201f3e00, 0xc4201f3ec0)
    /go/src/github.com/sdboyer/gps/solver.go:463 +0x2e1
github.com/sdboyer/gps.(*solver).Solve(0xc4203ae000, 0x1a, 0xc42000c0a4, 0x1a, 0xc420140a80)
    /go/src/github.com/sdboyer/gps/solver.go:312 +0x6a
main.main()
    /go/src/github.com/sdboyer/gps/example.go:46 +0x35d  
kris-nova:kops kris$ rm -rf ~/Workspace/kops/.repocache/
kris-nova:kops kris$ cd -
/go/src/github.com/sdboyer/gps
kris-nova:gps kris$ go build -o gps example.go && chmod +x gps && mv gps ~/Workspace/kops && cd ~/Workspace/kops/ && ./gps

..working gps logs here..

Maybe it has something to do with kops? Not sure..

sdboyer commented 7 years ago

...so weird. I mean just so, so weird. I wonder if this is something odd related to defer in main packages?

In any case, I think we can fix just by using an ioutil.TempDir() for the cache, rather than placing it in the current directory.

krisnova commented 7 years ago

Ah so I was using a 1.8 release candidate.. I just flipped over to 1.7.5

kris-nova:gps kris$ git pull origin master
From github.com:kris-nova/gps
 * branch            master     -> FETCH_HEAD
Already up-to-date.
kris-nova:gps kris$ git rev-parse HEAD
a04c90d985bb5980f22b6079a842e17c49f862d8
kris-nova:gps kris$ go version
go version go1.7.5 darwin/amd64
kris-nova:gps kris$ file ~/Workspace/kops/.repocache
/Users/kris/Workspace/kops/.repocache: directory
kris-nova:gps kris$ go build -o gps example.go && chmod +x gps && mv gps ~/Workspace/kops && cd ~/Workspace/kops/ && ./gps

.. working gps logs..
sdboyer commented 7 years ago

I pushed 8f8d2e5, which should sidestep the problem