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

Panic during Disconnect()

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Connections
    • Labels:
      None
    • Environment:
      macOS Mojave, Go 1.11.5

      When invoking defer client.Disconnect(nil), I get this panic:

      panic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x137641e]
      goroutine 1 [running]:github.com/mongodb/mongo-go-driver/x/mongo/driver/topology.(*Topology).selectServer(0xc0000cee60, 0x0, 0x0, 0xc000091860, 0x15c92a0, 0xc0001b28d0, 0xc000091800, 0x1886780, 0xbf0beda82116f280, 0xc0000b85f8, ...) /Users/fgm/src/go/src/github.com/mongodb/mongo-go-driver/x/mongo/driver/topology/topology.go:303 +0x1aegithub.com/mongodb/mongo-go-driver/x/mongo/driver/topology.(*Topology).SelectServer(0xc0000cee60, 0x0, 0x0, 0x15c92a0, 0xc0001b28d0, 0x0, 0x0, 0x0) /Users/fgm/src/go/src/github.com/mongodb/mongo-go-driver/x/mongo/driver/topology/topology.go:252 +0x12bgithub.com/mongodb/mongo-go-driver/x/mongo/driver.EndSessions(0x0, 0x0, 0xc0000c0800, 0x18a3f80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /Users/fgm/src/go/src/github.com/mongodb/mongo-go-driver/x/mongo/driver/end_sessions.go:27 +0xa2github.com/mongodb/mongo-go-driver/mongo.(*Client).endSessions(0xc000156500, 0x0, 0x0) /Users/fgm/src/go/src/github.com/mongodb/mongo-go-driver/mongo/client.go:170 +0x134github.com/mongodb/mongo-go-driver/mongo.(*Client).Disconnect(0xc000156500, 0x0, 0x0, 0xc0001bcec0, 0xc00011df60) /Users/fgm/src/go/src/github.com/mongodb/mongo-go-driver/mongo/client.go:103 +0x43main.close(0xc000156500) /Users/fgm/src/go/src/code.osinet.fr/fgm/go__course__exercises/mongodb_official/mongodb.go:90 +0x33main.main() /Users/fgm/src/go/src/code.osinet.fr/fgm/go__course__exercises/mongodb_official/mongodb.go:105 +0x99
      Process finished with exit code 2
      

      The issue can be fixed by calling client.Disconnect(context.Background()) instead, but this feel like an error, and @craig wilson sait to file it here.

            Assignee:
            Unassigned Unassigned
            Reporter:
            fgm@osinet.fr Frédéric G. MARAND
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: