[SERVER-77573] avoid copying invalid iterator in StreamableReplicaSetMonitor Created: 30/May/23  Updated: 07/Jul/23  Resolved: 07/Jul/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: [DO NOT USE] Backlog - Sharding NYC
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-78409 Mongo client fails with Error: attemp... Closed
Assigned Teams:
Sharding NYC
Operating System: ALL
Participants:
Linked BF Score: 37

 Description   

Fixes BF-28895.

The GLIBCXX_DEBUG macros complain about making a copy of an invalidated iterator, whether you use it or not.

We copy a potentially invalid iterator here, but we don't use it unless other conditions indicate that the bound copy is still valid.
https://github.com/10gen/mongo/blob/0e6a660c41d4a07228837835f572daedd3683fc0/src/mongo/client/streamable_replica_set_monitor.cpp#L422

We don't use it, but the instrumentation doesn't know that. It just complains about the copy, so we can conditionally copy to fix this problem.



 Comments   
Comment by Billy Donahue [ 31/May/23 ]

more details in BF-28895.

I don't understand how the iterator could be invalidated between lines 417 and 422.

https://github.com/10gen/mongo/blob/0e6a660c41d4a07228837835f572daedd3683fc0/src/mongo/client/streamable_replica_set_monitor.cpp#L417-L422

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