[GODRIVER-786] Panic during Disconnect() Created: 28/Jan/19  Updated: 07/Apr/23  Resolved: 28/Jan/19

Status: Closed
Project: Go Driver
Component/s: Connections
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Frédéric G. MARAND Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

macOS Mojave, Go 1.11.5


Issue Links:
Duplicate
duplicates GODRIVER-767 client.Disconnect(nil) causes a panic Closed

 Description   

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.


Generated at Thu Feb 08 08:34:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.