Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-692

SingleResult.Decode to struct panics with nil pointer dereference

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.2.0
    • Affects Version/s: 0.1.0
    • Component/s: None
    • None

      In updating the tools/go-driver POC to the new API, I found a panic. Decoding a SingleResult from RunCommand to a struct panics – apparently because the registry is nil. 

      Stack trace:

      panic: runtime error: invalid memory address or nil pointer dereference
      [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11e5038]
      
      goroutine 1 [running]:
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson/bsoncodec.(*Registry).LookupDecoder(0x0, 0x1696440, 0x1508ae0, 0x1696440, 0x1508ae0, 0x199, 0xc0001584c0)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson/bsoncodec/registry.go:319 +0x48
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson.(*Decoder).Decode(0xc00016e220, 0x14a7b60, 0xc000152270, 0x14f95e0, 0xc00016e220)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson/decoder.go:82 +0x16d
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson.unmarshalFromReader(0x0, 0xc000158400, 0x1693cc0, 0xc0001584c0, 0x14a7b60, 0xc000152270, 0x0, 0x0)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson/unmarshal.go:92 +0xe4
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson.UnmarshalWithRegistry(0x0, 0xc000244000, 0xcb, 0x180, 0x14a7b60, 0xc000152270, 0x0, 0x0)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/bson/unmarshal.go:45 +0x11f
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/mongo.(*SingleResult).Decode(0xc000158480, 0x14a7b60, 0xc000152270, 0x0, 0x0)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-go-driver/mongo/single_result.go:43 +0x84
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-tools-common/db.(*SessionProvider).GetNodeType(0xc00000cd00, 0x146b604, 0xc00000cd00, 0x1566690, 0xc00000cd00)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-tools-common/db/command.go:131 +0x23e
      github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-tools-common/db.(*SessionProvider).IsMongos(0xc00000cd00, 0xc0001521b0, 0x15584f6, 0x1c)
              /Users/david/golang/src/github.com/mongodb/mongo-tools/vendor/github.com/mongodb/mongo-tools-common/db/command.go:157 +0x2f
      main.main()
              /Users/david/golang/src/github.com/mongodb/mongo-tools/mongotop/main/mongotop.go:96 +0x3d0
      

            Assignee:
            david.golden@mongodb.com David Golden
            Reporter:
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: