[GODRIVER-791] Panic on cursor Close with a dead server Created: 29/Jan/19  Updated: 28/Oct/23  Resolved: 01/Feb/19

Status: Closed
Project: Go Driver
Component/s: Error Handling
Affects Version/s: 0.0.2
Fix Version/s: 0.3.0

Type: Bug Priority: Major - P3
Reporter: Ryan Wynn Assignee: Kristofer Brandow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux



 Description   

Received the following panic when doing some negative testing.  This seems to have occurred when Close() was called on a cursor after Next() returned false. 

I started a long running query with MongoDB running and brought mongod down in the middle of it returning results.   So mongod was down at the time of the Close call.  

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x743edc]
goroutine 59 [running]:
github.com/mongodb/mongo-go-driver/x/mongo/driver/topology.(*cursor).legacy(...)
/home/vagrant/go/pkg/mod/github.com/mongodb/mongo-go-driver@v0.2.0/x/mongo/driver/topology/cursor.go:142
github.com/mongodb/mongo-go-driver/x/mongo/driver/topology.(*cursor).Close(0xc00007ab40, 0x9ab240, 0xc0000140b0, 0x0, 0x0)
/home/vagrant/go/pkg/mod/github.com/mongodb/mongo-go-driver@v0.2.0/x/mongo/driver/topology/cursor.go:207 +0x16c



 Comments   
Comment by Githook User [ 01/Feb/19 ]

Author:

{'name': 'Kris Brandow', 'email': 'kris@mongodb.com', 'username': 'skriptble'}

Message: Fix cursor types and implement BatchCursor

GODRIVER-3
GODRIVER-759
GODRIVER-791

Change-Id: I7d4121e7fffcfadd7427a6fc64d97d4c131acbbe
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/d23c3a5ccaad4abaa2056f0ba9d174f0b06ccddf

Comment by Ryan Wynn [ 29/Jan/19 ]

Also, when the heartbeat fails to get server info, it still returns server info that is truncated to the basics.

https://github.com/mongodb/mongo-go-driver/blob/master/x/mongo/driver/topology/server.go#L437

But I think that will cause problems because that basic info doesn't include a bunch of things like the wire version...

https://github.com/mongodb/mongo-go-driver/blob/master/x/network/description/server.go#L30

 

 

Comment by Ryan Wynn [ 29/Jan/19 ]

I think maybe the description updates should all be guarded by nil checks

https://github.com/mongodb/mongo-go-driver/blob/master/x/mongo/driver/topology/server.go#L333

Some of the updateDescription calls in this file check for nil before setting, but others do not.  

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