[SERVER-50127] Coverity analysis defect 116104: Using invalid iterator Created: 05/Aug/20  Updated: 29/Oct/23  Resolved: 13/Aug/20

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-48417 adjust startup to resume index build ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2020-08-24
Participants:

 Description   

Using invalid iterator

Undefined behavior may result; the program may crash or subtly misbehave. An invalid or past-the-end iterator is being used
/src/mongo/db/catalog/multi_index_block.cpp:244: INVALIDATE_ITERATOR 116104 Function "end" creates an iterator.
/src/mongo/db/catalog/multi_index_block.cpp:244: INVALIDATE_ITERATOR 116104 Assigning: "indexResumeInfo" = "std::find_if(resumeInfoIndexes.begin(), resumeInfoIndexes.end(), mongo::MultiIndexBlock::init(mongo::OperationContext *, mongo::Collection *, std::vector<mongo::BSONObj, std::allocator<mongo::BSONObj> > const &, std::function<mongo::Status (std::vector<mongo::BSONObj, std::allocator<mongo::BSONObj> > &)>, boost::optional<mongo::ResumeIndexInfo> const &)::[lambda(mongo::IndexSorterInfo const &) (instance 1)](info))".
/src/mongo/db/catalog/multi_index_block.cpp:251: INVALIDATE_ITERATOR 116104 Dereferencing iterator "indexResumeInfo" though it is already past the end of its container.



 Comments   
Comment by Githook User [ 12/Aug/20 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-50127 fail index build resume if we cannot find resume info using index spec
Branch: master
https://github.com/mongodb/mongo/commit/b83bc195a32e3ecd2f5120f5e76a9f8726dd2fad

Comment by Benety Goh [ 07/Aug/20 ]

The std::find_if() searches a vector that is constructed from state written to disk before a clean shutdown. It's very unlikely we should fail to locate the entry unless the on-disk state was somehow corrupted before startup.

Generated at Thu Feb 08 05:21:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.