[SERVER-74680] Coverity analysis defect 135356: Using invalid iterator Created: 07/Mar/23  Updated: 29/Oct/23  Resolved: 27/Mar/23

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

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

Issue Links:
Problem/Incident
is caused by SERVER-74472 Add support for truncating a given ra... Closed
Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2023-04-03
Participants:

 Description   

Using invalid iterator: src/mongo/db/storage/devnull/ephemeral_catalog_record_store.cpp:90

Undefined behavior may result; the program may crash or subtly misbehave. An invalid or past-the-end iterator is being used
/src/mongo/db/storage/devnull/ephemeral_catalog_record_store.cpp:90: INVALIDATE_ITERATOR 135356 Function "end" creates an iterator.
/src/mongo/db/storage/devnull/ephemeral_catalog_record_store.cpp:90: INVALIDATE_ITERATOR 135356 Assigning: "<temporary>" = "this->_data->records.end()".
/src/mongo/db/storage/devnull/ephemeral_catalog_record_store.cpp:90: INVALIDATE_ITERATOR 135356 "it" testing equal to "this->_data->records.end()".
/src/mongo/db/storage/devnull/ephemeral_catalog_record_store.cpp:96: INVALIDATE_ITERATOR 135356 Dereferencing iterator "it" though it is already past the end of its container.



 Comments   
Comment by Githook User [ 24/Mar/23 ]

Author:

{'name': 'Jordi Olivares Provencio', 'email': 'jordi.olivares-provencio@mongodb.com', 'username': 'jordiolivares'}

Message: SERVER-74680 Refactor EFT truncation
Branch: master
https://github.com/mongodb/mongo/commit/d01f286e19bea0b5d035acf520132f5fee68ec27

Comment by Kyle Suarez [ 07/Mar/23 ]

I believe the complaint is that if _data->records.begin() == _data->records.end(), then it is undefined behavior to access _data, even though the two loops prevent the iterator from being incremented.

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