MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0029777Open CASCADE[OCCT] OCCT:Foundation Classespublic2018-05-15 19:242018-05-23 16:27
Reportermsv 
Assigned Tomsv 
PrioritynormalSeverityminor 
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version[OCCT] 7.2.0 
Target Version[OCCT] 7.4.0*Fixed in Version 
Summary0029777: Foundation Classes - The methods of moving of one NCollection_Sequence to another are unsafe
DescriptionThe class NCollection_Sequence has methods

Append
Prepend
InserAfter
InsertBefore

that take another sequence and move its content to the current one.

If the sequences have different allocators this causes inconsistent data structure with high probability of application crash.

It is needed to change these methods in a way similar to NCollection_List.
TagsNo tags attached.
Test case number
Attached Files

- Relationships

-  Notes
(0076126)
git (administrator)
2018-05-23 10:19

Branch CR29777 has been created by msv.

SHA-1: 50378c501b77fbe50ae147cc6331b35664bb42ac


Detailed log of new commits:

Author: msv
Date: Wed May 23 10:18:49 2018 +0300

    0029777: Foundation Classes - The methods of moving of one NCollection_Sequence to another are unsafe
    
    Make the methods Append, Prepend, InsertBefore and InsertAfter, which take another sequence as an argument, copying the sequence instead of joining if the allocators are different.
    
    Add test cases for collection classes.
(0076167)
kgv (developer)
2018-05-23 13:03

+      // No - this sequence has different memory scope
+      Iterator anIter;
+      prependSeq((const Node *)theSeq.myFirstItem, theIndex + 1);
+      theSeq.Clear();

anIter seems to be an artifact.

   //! InsertBefore theIndex another sequence
   void InsertBefore (const Standard_Integer theIndex,
                      NCollection_Sequence&  theSeq)
   { InsertAfter (theIndex-1, theSeq); }

   //! InsertAfter theIndex theItem
   void InsertAfter  (const Standard_Integer theIndex,
                      NCollection_Sequence&  theSeq)

I think it would be good documenting theSeq behavior as in case of Append().

I never got what is the use case for these weird API like Append(NCollection_Sequence& theSeq) moving the given sequence; from my point of view, this should be done with an extra Boolean flag.
(0076183)
git (administrator)
2018-05-23 16:22

Branch CR29777 has been updated by msv.

SHA-1: 5d4b424b47cd834382c02b33022fe091cf98db84


Detailed log of new commits:

Author: msv
Date: Wed May 23 16:22:17 2018 +0300

    # considering remarks

(0076187)
msv (developer)
2018-05-23 16:27

The method Append(NCollection_Sequence& theSeq) uses the common symantic with the List class. It is used when the items of a temporary container are to be remembered in the other container. In order to not perform additional allocations the chain is just joined to another list.

- Issue History
Date Modified Username Field Change
2018-05-15 19:24 msv New Issue
2018-05-15 19:24 msv Assigned To => abv
2018-05-15 19:25 msv Relationship added parent of 0029774
2018-05-23 10:19 git Note Added: 0076126
2018-05-23 10:20 msv Assigned To abv => msv
2018-05-23 10:20 msv Status new => assigned
2018-05-23 13:03 kgv Note Added: 0076167
2018-05-23 16:22 git Note Added: 0076183
2018-05-23 16:27 msv Note Added: 0076187


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker