[GODRIVER-1079] Crash due to nil *net.Conn when server is restarted with open change stream Created: 22/May/19  Updated: 27/Oct/23  Resolved: 09/Jul/19

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

Type: Bug Priority: Major - P3
Reporter: Joël Gähwiler Assignee: Emmanuel Eppinger (Inactive)
Resolution: Gone away Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I got the following panic when restarting the MongoDB server with an open change stream. I'm using the master branch of the driver and MongoDB 4.0.4.

You can run the following example yourself and restart the server to get the crash:
https://github.com/256dpi/fire/tree/official-driver/example

panic: runtime error: invalid memory address or nil pointer dereferencepanic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x149cc39]
goroutine 36 [running]:go.mongodb.org/mongo-driver/x/mongo/driver/topology.newConnection(0x184f4a0, 0xc0000c2048, 0xc0002e0280, 0xf, 0xc0002e6050, 0x2, 0x2, 0x5509850, 0xc00043e300, 0xc000168e00) /Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driver/topology/connection.go:101 +0x739go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).get(0xc0000ac120, 0x184f4a0, 0xc0000c2048, 0x1, 0x0, 0x0) /Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driver/topology/pool.go:157 +0xf6go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).ConnectionLegacy(0xc0002ee000, 0x184f4a0, 0xc0000c2048, 0xa7000000, 0x2540be400, 0x0, 0x0) /Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driver/topology/server.go:244 +0xb8go.mongodb.org/mongo-driver/x/mongo/driverlegacy.KillCursors(0x184f4a0, 0xc0000c2048, 0xc0000c78a0, 0xc, 0xc0000c78ad, 0x4, 0x1842c40, 0xc0002ee000, 0x4b861a30c0352624, 0x0, ...) /Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driverlegacy/kill_cursors.go:36 +0x2b0go.mongodb.org/mongo-driver/mongo.(*ChangeStream).loopNext(0xc000360140, 0x184f4a0, 0xc0000c2048) /Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/mongo/change_stream.go:558 +0x35bgo.mongodb.org/mongo-driver/mongo.(*ChangeStream).Next(0xc000360140, 0x0, 0x0, 0x0) /Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/mongo/change_stream.go:507 +0x169github.com/256dpi/fire/coal.(*Stream).tail(0xc0000c4460, 0xc0000b73b0, 0xc000169fb0, 0x0, 0x0) /Users/256dpi/Development/GitHub/256dpi/fire/coal/stream.go:166 +0x27agithub.com/256dpi/fire/coal.(*Stream).open(0xc0000c4460) /Users/256dpi/Development/GitHub/256dpi/fire/coal/stream.go:122 +0xc3created by github.com/256dpi/fire/coal.OpenStream /Users/256dpi/Development/GitHub/256dpi/fire/coal/stream.go:76 +0xc1



 Comments   
Comment by Joël Gähwiler [ 08/Jun/19 ]

I can confirm that the issue has been fixed on master!

Comment by Emmanuel Eppinger (Inactive) [ 04/Jun/19 ]

Also, I think this might have been fixed in another ticket. Would you be able to pull from master and see if the issue persists?

Comment by Emmanuel Eppinger (Inactive) [ 04/Jun/19 ]

It seems like that branch has been deleted. Would it be possible to get a reproduction?

Comment by Joël Gähwiler [ 22/May/19 ]

Here is the stack trace better formatted.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x149cc39]
 
goroutine 36 [running]:
go.mongodb.org/mongo-driver/x/mongo/driver/topology.newConnection(0x184f4a0, 0xc0000c2048, 0xc0002e0280, 0xf, 0xc0002e6050, 0x2, 0x2, 0x5509850, 0xc00043e300, 0xc000168e00)
	/Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driver/topology/connection.go:101 +0x739
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).get(0xc0000ac120, 0x184f4a0, 0xc0000c2048, 0x1, 0x0, 0x0)
	/Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driver/topology/pool.go:157 +0xf6
go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).ConnectionLegacy(0xc0002ee000, 0x184f4a0, 0xc0000c2048, 0xa7000000, 0x2540be400, 0x0, 0x0)
	/Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driver/topology/server.go:244 +0xb8
go.mongodb.org/mongo-driver/x/mongo/driverlegacy.KillCursors(0x184f4a0, 0xc0000c2048, 0xc0000c78a0, 0xc, 0xc0000c78ad, 0x4, 0x1842c40, 0xc0002ee000, 0x4b861a30c0352624, 0x0, ...)
	/Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/x/mongo/driverlegacy/kill_cursors.go:36 +0x2b0
go.mongodb.org/mongo-driver/mongo.(*ChangeStream).loopNext(0xc000360140, 0x184f4a0, 0xc0000c2048)
	/Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/mongo/change_stream.go:558 +0x35b
go.mongodb.org/mongo-driver/mongo.(*ChangeStream).Next(0xc000360140, 0x0, 0x0, 0x0)
	/Users/256dpi/Development/Go/pkg/mod/go.mongodb.org/mongo-driver@v1.0.1-0.20190520233249-537a129acde0/mongo/change_stream.go:507 +0x169
github.com/256dpi/fire/coal.(*Stream).tail(0xc0000c4460, 0xc0000b73b0, 0xc000169fb0, 0x0, 0x0)
	/Users/256dpi/Development/GitHub/256dpi/fire/coal/stream.go:166 +0x27a
github.com/256dpi/fire/coal.(*Stream).open(0xc0000c4460)
	/Users/256dpi/Development/GitHub/256dpi/fire/coal/stream.go:122 +0xc3
created by github.com/256dpi/fire/coal.OpenStream
	/Users/256dpi/Development/GitHub/256dpi/fire/coal/stream.go:76 +0xc1

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