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

Panic on dep ensure #367

Closed
nathanielc opened this issue Apr 7, 2017 · 6 comments
Closed

Panic on dep ensure #367

nathanielc opened this issue Apr 7, 2017 · 6 comments
Labels

Comments

@nathanielc
Copy link
Contributor

nathanielc commented Apr 7, 2017

I get this panic when running dep ensure with any options or packages listed.
The fromErr is nil which is causing the panic.

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

goroutine 1 [running]:
panic(0x7b57c0, 0xc420012110)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree.wmToReach.func3(0xc42020b720, 0x1, 0x1, 0xc420249dc1, 0x1e)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree/pkgtree.go:603 +0x78
github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree.wmToReach.func4(0xc420249dc1, 0x1e, 0xc42020b720, 0x1, 0x1, 0xc42020b701)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree/pkgtree.go:742 +0x468
github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree.wmToReach.func4(0xc4204bac60, 0x2b, 0xc42020b720, 0x1, 0x1, 0xc4203c0c00)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree/pkgtree.go:699 +0xd36
github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree.wmToReach(0xc4205f4300, 0x1, 0x81e040, 0x4)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree/pkgtree.go:781 +0xc8b
github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree.PackageTree.ToReachMap(0xc420208cc0, 0x18, 0xc42023be90, 0x10000, 0xc42033bbc0, 0x9d9920, 0xc420320350)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/pkgtree/pkgtree.go:472 +0x281
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).getImportsAndConstraintsOf(0xc4203741e0, 0xc420208cc0, 0x18, 0x0, 0x0, 0x9d9920, 0xc420320350, 0xc4203114c0, 0x1, 0x1, ...)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:525 +0x1df
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).check(0xc4203741e0, 0xc420208cc0, 0x18, 0x0, 0x0, 0x9d9920, 0xc420320350, 0xc4203114c0, 0x1, 0x1, ...)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/satisfy.go:34 +0x1a6
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).findValidVersion(0xc4203741e0, 0xc4204ea000, 0xc4203114c0, 0x1, 0x1, 0x0, 0xc4203114c0)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:795 +0x2fd
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).createVersionQueue(0xc4203741e0, 0xc420208cc0, 0x18, 0x0, 0x0, 0xc4203114c0, 0x1, 0x1, 0x0, 0x0, ...)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:768 +0x8ff
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).solve(0xc4203741e0, 0x0, 0x0, 0xc42033bc20)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:385 +0x471
github.com/golang/dep/vendor/github.com/sdboyer/gps.(*solver).Solve(0xc4203741e0, 0x43, 0xc42001802a, 0x1d, 0xc4201b4000)
        /usr/local/gopath/src/github.com/golang/dep/vendor/github.com/sdboyer/gps/solver.go:336 +0x8e
main.(*ensureCommand).Run(0xc4201357e0, 0xc420153550, 0xc42000c230, 0x0, 0x0, 0x0, 0x0)
        /usr/local/gopath/src/github.com/golang/dep/cmd/dep/ensure.go:145 +0x4a2
main.main()
        /usr/local/gopath/src/github.com/golang/dep/cmd/dep/main.go:97 +0x652

I added this debug log statement

log.Println(from, errmap)

Here is the output of the log statement (addded some manual formatting).

github.com/gogo/protobuf/types
 map[
github.com/gogo/protobuf/jsonpb:"github.com/gogo/protobuf/jsonpb" imports "github.com/gogo/protobuf/types", which contains malformed code: no package exists at "github.com/gogo/protobuf/types" 
github.com/gogo/protobuf/test/theproto3/combos/unmarshaler:"github.com/gogo/protobuf/test/theproto3/combos/unmarshaler" imports "github.com/gogo/protobuf/test/combos/both", which contains malformed code: /gopath/pkg/dep/sources/https---github.com-gogo-protobuf/test/combos/both/thetest.pb.go:1:1: expected 'package', found 'EOF' 
github.com/gogo/protobuf/protobuf/google/protobuf:"github.com/gogo/protobuf/protobuf/google/protobuf" contains malformed code: no buildable Go source files in /gopath/pkg/dep/sources/https---github.com-gogo-protobuf/protobuf/google/protobuf 
github.com/gogo/protobuf/test/oneof3/combos:"github.com/gogo/protobuf/test/oneof3/combos" contains malformed code: no buildable Go source files in /gopath/pkg/dep/sources/https---github.com-gogo-protobuf/test/oneof3/combos 
github.com/gogo/protobuf/test/mapsproto2/combos:"github.com/gogo/protobuf/test/mapsproto2/combos" contains malformed code: no buildable Go source files in /gopath/pkg/dep/sources/https---github.com-gogo-protobuf/test/mapsproto2/combos 
github.com/gogo/protobuf/test/theproto3/combos/both:"github.com/gogo/protobuf/test/theproto3/combos/both" imports "github.com/gogo/protobuf/test/combos/both", which contains malformed code: /gopath/pkg/dep/sources/https---github.com-gogo-protobuf/test/combos/both/thetest.pb.go:1:1: expected 'package', found 'EOF' 
github.com/gogo/protobuf/test/combos/both:"github.com/gogo/protobuf/test/combos/both" contains malformed code: /gopath/pkg/dep/sources/https---github.com-gogo-protobuf/test/combos/both/thetest.pb.go:1:1: expected 'package', found 'EOF'
]
@sdboyer
Copy link
Member

sdboyer commented Apr 15, 2017

Thanks for the bug report!

It looks like this is probably basically the same issue as #351.

@sdboyer sdboyer added the bug label Apr 15, 2017
@sdboyer
Copy link
Member

sdboyer commented Apr 28, 2017

(Closing this as a dup of #351)

@sdboyer sdboyer closed this as completed Apr 28, 2017
@nathanielc
Copy link
Contributor Author

I am still getting a panic when fromErr is nil.

Here is an updated stack trace:

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

goroutine 1 [running]:
github.com/golang/dep/internal/gps/pkgtree.wmToReach.func3(0xc420314b90, 0x1, 0x1, 0xc42048e1e1, 0x1e)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/pkgtree/pkgtree.go:632 +0x78
github.com/golang/dep/internal/gps/pkgtree.wmToReach.func4(0xc42048e1e1, 0x1e, 0xc420314b90, 0x1, 0x1, 0xc420314b01)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/pkgtree/pkgtree.go:771 +0x462
github.com/golang/dep/internal/gps/pkgtree.wmToReach.func4(0xc4201d96a0, 0x1f, 0xc420314b90, 0x1, 0x1, 0x1)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/pkgtree/pkgtree.go:728 +0xd08
github.com/golang/dep/internal/gps/pkgtree.wmToReach(0xc420570238, 0xc420570201, 0xc4205701f8, 0xc420608b18)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/pkgtree/pkgtree.go:810 +0xd1c
github.com/golang/dep/internal/gps/pkgtree.PackageTree.ToReachMap(0xc4202af400, 0x18, 0xc4202434a0, 0x10001, 0xc4204a9ec0, 0xa7d1c0, 0xc4202f7550)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/pkgtree/pkgtree.go:501 +0x2c0
github.com/golang/dep/internal/gps.(*solver).getImportsAndConstraintsOf(0xc4200d6480, 0xc4202af400, 0x18, 0x0, 0x0, 0xa7d1c0, 0xc4202f7550, 0xc4202f71b0, 0x1, 0x1, ...)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/solver.go:537 +0x1f7
github.com/golang/dep/internal/gps.(*solver).check(0xc4200d6480, 0xc4202af400, 0x18, 0x0, 0x0, 0xa7d1c0, 0xc4202f7550, 0xc4202f71b0, 0x1, 0x1, ...)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/satisfy.go:43 +0x1f0
github.com/golang/dep/internal/gps.(*solver).findValidVersion(0xc4200d6480, 0xc42019a5a0, 0xc4202f71b0, 0x1, 0x1, 0x0, 0xc4202f71b0)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/solver.go:807 +0x2d5
github.com/golang/dep/internal/gps.(*solver).createVersionQueue(0xc4200d6480, 0xc4202af400, 0x18, 0x0, 0x0, 0xc4202f71b0, 0x1, 0x1, 0x0, 0x0, ...)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/solver.go:780 +0xafc
github.com/golang/dep/internal/gps.(*solver).solve(0xc4200d6480, 0x0, 0x0, 0x2f)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/solver.go:397 +0x471
github.com/golang/dep/internal/gps.(*solver).Solve(0xc4200d6480, 0x43, 0xa79100, 0xac71e0, 0xc42001207a)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/internal/gps/solver.go:348 +0xab
main.(*ensureCommand).Run(0xc4201494c0, 0xc42014b600, 0xc420098080, 0x0, 0x0, 0x0, 0x0)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/cmd/dep/ensure.go:148 +0x3c8
main.(*Config).Run(0xc420076f00, 0xc420076f00)
        /home/nathanielc/projects/dep/src/github.com/golang/dep/cmd/dep/main.go:159 +0x8b3
main.main()
        /home/nathanielc/projects/dep/src/github.com/golang/dep/cmd/dep/main.go:44 +0x253

Also this patch makes the issue go away:

diff --git a/internal/gps/pkgtree/pkgtree.go b/internal/gps/pkgtree/pkgtree.go
index 2713290..74c597f 100644
--- a/internal/gps/pkgtree/pkgtree.go
+++ b/internal/gps/pkgtree/pkgtree.go
@@ -627,6 +627,11 @@ func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*Prob
                // an empty path here.

                fromErr := errmap[from]
+               if fromErr == nil {
+                       fromErr = &ProblemImportError{
+                               Err: fmt.Errorf("unknown error for %q", from),
+                       }
+               }
                err := &ProblemImportError{
                        Err:   fromErr.Err,
                        Cause: make([]string, 0, len(path)+len(fromErr.Cause)+1),

I don't get a panic anymore and somehow the dep ensure command finishes without any error and does what I expected.

@sdboyer
Copy link
Member

sdboyer commented May 23, 2017

Right, we could do that. And I suppose we should, in the short term, just so we don't have the panic here. (So, maybe go ahead with a PR 😄 )

My hesitation to move on it has been because it's not supposed to be possible for that algorithm to have bad data in this way. Actually sitting down and identifying the full set of conditions under which this case occur is the proper fix - but unfortunately, that takes time and focus, and I haven't had much to spare of that recently 😦

@nathanielc
Copy link
Contributor Author

Yeah, I am not suggesting this is a fix, which is why I didn't submit a PR. (I can submit a PR if you think its worth it).

My intent was to add more information to the issue but I suppose it would be more helpful to have commented on the linked issue.

@sdboyer
Copy link
Member

sdboyer commented May 23, 2017

Ah, gotcha 👍

Yes, please do submit a PR with that temporary fix. If you could include a FIXME notice that it's just a band-aid, then open a follow-up issue as well, that'd be ideal. We don't need to keep a known panic condition open just as a reminder to fix a problem - a ticket will do 😄

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