[GODRIVER-298] Passing a nil context.Next to Cursor#Next panics Created: 24/Mar/18  Updated: 28/Oct/23  Resolved: 26/Apr/18

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

Type: Bug Priority: Major - P3
Reporter: Eric Daniels (Inactive) Assignee: Sam Kleinman (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

CappedConnection uses the context to potentially cancel waiting for a permit from the Semaphore but the Cursor#Next (cursorImpl) method does not create a context.Background() when it is passed nil.

Backtrace:

github.com/mongodb/mongo-go-driver/mongo/internal.(*Semaphore).Wait(0xc448c976a0, 0x0, 0x0, 0x1d, 0xc4490bb520)
	/Users/eric/go/src/github.com/mongodb/mongo-go-driver/mongo/internal/semaphore.go:43 +0x47
github.com/mongodb/mongo-go-driver/mongo/private/conn.CappedProvider.func1(0x0, 0x0, 0x1d, 0x5, 0x5, 0x1)
	/Users/eric/go/src/github.com/mongodb/mongo-go-driver/mongo/private/conn/provider.go:32 +0x53
github.com/mongodb/mongo-go-driver/mongo/private/server.(*Server).Connection(0xc446de0f00, 0x0, 0x0, 0x2, 0x2, 0xc4490bb520, 0x1d)
	/Users/eric/go/src/github.com/mongodb/mongo-go-driver/mongo/private/server/server.go:127 +0x6e
github.com/mongodb/mongo-go-driver/mongo/private/ops.(*SelectedServer).Connection(0xc4474e5ee0, 0x0, 0x0, 0x4f4878c, 0x5, 0xc4490bb520, 0x1d)
	<autogenerated>:1 +0x50
github.com/mongodb/mongo-go-driver/mongo/private/ops.(*cursorImpl).getMore(0xc444a5bf80, 0x0, 0x0)
	/Users/eric/go/src/github.com/mongodb/mongo-go-driver/mongo/private/ops/cursor.go:257 +0x26f
github.com/mongodb/mongo-go-driver/mongo/private/ops.(*cursorImpl).Next(0xc444a5bf80, 0x0, 0x0, 0xc449138ea0)
	/Users/eric/go/src/github.com/mongodb/mongo-go-driver/mongo/private/ops/cursor.go:152 +0x5e



 Comments   
Comment by Githook User [ 26/Apr/18 ]

Author:

{'email': 'garen@tychoish.com', 'username': 'tychoish', 'name': 'tycho garen'}

Message: GODRIVER-298: support nil context to next method

Change-Id: Ia4005ae06ec7ae7e7525c5745a85e5ad77a058be
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/6b0824646cfdd9915b83f44534c50c7829f95db1

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