[SERVER-19555] Coverity analysis defect 73480: Using invalid iterator Created: 23/Jul/15  Updated: 24/Jul/15  Resolved: 24/Jul/15

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

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

An invalid or past-the-end iterator is being used

Defect 73480 (STATIC_C)
Checker INVALIDATE_ITERATOR (subcategory none)
File: /src/mongo/executor/task_executor_test_common.cpp
Function mongo::executor::<unnamed>::CET_CallbackHandleComparison::_doTest()
/src/mongo/executor/task_executor_test_common.cpp, line: 488
Function "end" creates an iterator.

        ASSERT_TRUE(cbs.end() != foundHandle);

/src/mongo/executor/task_executor_test_common.cpp, line: 488
"foundHandle" testing equal to "cbs.end()".

        ASSERT_TRUE(cbs.end() != foundHandle);

/src/mongo/executor/task_executor_test_common.cpp, line: 489
Dereferencing iterator "foundHandle" though it is already past the end of its container.

        ASSERT_TRUE(cbHandle1 == *foundHandle);

File: /src/mongo/executor/task_executor_test_common.cpp
Function mongo::executor::<unnamed>::CET_CallbackHandleComparison::_doTest()
/src/mongo/executor/task_executor_test_common.cpp, line: 486
Function "end" creates an iterator.

        std::vector<TaskExecutor::CallbackHandle>::iterator foundHandle =

/src/mongo/executor/task_executor_test_common.cpp, line: 486
Assigning: "foundHandle" = "std::find(cbs.begin(), cbs.end(), cbHandle1)".

        std::vector<TaskExecutor::CallbackHandle>::iterator foundHandle =

/src/mongo/executor/task_executor_test_common.cpp, line: 489
Dereferencing iterator "foundHandle" though it is already past the end of its container.

        ASSERT_TRUE(cbHandle1 == *foundHandle);



 Comments   
Comment by Andy Schwerin [ 24/Jul/15 ]

This is a false positive from coverity. If the ASSERT_TRUE at 488 fails, the ASSERT_TRUE at 489 will never run.

Generated at Thu Feb 08 03:51:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.