View Issue Details

IDProjectCategoryView StatusLast Update
0027367Open CASCADEOCCT:Foundation Classespublic2016-11-22 23:27
ReporterabkAssigned Toabv 
PrioritynormalSeverityminor 
Status closedResolutionno change required 
Product Version7.0.0 
Summary0027367: The last element remove crash during NCollection_List iteration
DescriptionThe NCollection_List iteration crashes if the list last element is removed during the iteration.
Steps To ReproduceNCollection_List<Standard_Integer> aList;
aList.Prepend(0);
aList.Prepend(1);
NCollection_List<Standard_Integer>::Iterator aIt(aList);
for (; aIt.More(); aIt.Next())
{
  if (aIt.Value() == 0)
  {
    aList.Remove(aIt);
  }
}
TagsNo tags attached.
Test case number

Activities

abv

2016-11-21 11:21

manager   ~0060599

The cycle given in Steps to Reproduce is organized in incorrect way. When element is removed from the list, iterator is modified to point to the next element, and Next() should not be called. If the cycle is corrected, the problem will not appear any more.

Note that this is not specific to lists, but relevant for iteration by any collection.

The immediate reason of exception is that method Next() causes access violation if iterator is in stop state (More() returns False). The protection could be added, however it may affect performance and would be rather useless, letting the problem to remain unnoticed.

Alexander, please confirm that you agree with my conclusion (you might need to correct the code where you found this issue), so that I could close the issue.

abk

2016-11-22 14:27

developer   ~0060677

The conclusion is acceptable for me.
Please process the bug by a way that is right in your opinion.

Issue History

Date Modified Username Field Change
2016-04-08 18:14 abk New Issue
2016-04-08 18:14 abk Assigned To => abv
2016-11-21 11:21 abv Note Added: 0060599
2016-11-21 11:21 abv Assigned To abv => abk
2016-11-21 11:21 abv Status new => feedback
2016-11-22 14:27 abk Note Added: 0060677
2016-11-22 14:27 abk Assigned To abk => abv
2016-11-22 14:27 abk Status feedback => assigned
2016-11-22 23:27 abv Status assigned => closed
2016-11-22 23:27 abv Resolution open => no change required
2016-11-22 23:27 abv Target Version 7.1.0 =>