View Issue Details

IDProjectCategoryView StatusLast Update
0013261Open CASCADEOCCT:Foundation Classespublic2012-10-25 12:57
ReporterabvAssigned Toilv 
PrioritynormalSeveritytrivial 
Status closedResolutionno change required 
OSAll 
Summary0013261: Ensure correct allocation/deallocation of memory blocks of size 0
DescriptionAccording to C++ standard (ISO/IEC 14882, 3.7.3.1, clause 2), allocator
functions in C++ must allow allocation (and, respectively, deallocation) of
blocks of zero size, resulting in non-zero pointer.

Current implementation of OCC optimized memory manager (class Standard_MMgrOpt)
does not satisfy this requirement: though the allocation request for zero-sized
block will be correctly processed and give non-zero pointer, on freeing this
block the zero value stored in the beginning of it will be misinterpreted as if
the block was allocated as 'big' one.

Note that if we allow blocks of zero size, we must reserve space for them in
the free list. Alternatively, we may extend size of such blocks to 16 bytes...

Fixing this bug can be combined with IMP OCC13258 (see relevant comment to that
bug)

P.S. Note that this bug has not been checked in practice, thus it is possible
(though unlikely) that I am wrong...
TagsNo tags attached.
Test case number

Relationships

related to 0023033 closeddbv Open CASCADE Standard_MMgrOpt::Reallocate behavior must be similar to "realloc" 

Activities

dbv

2012-03-30 11:08

developer   ~0020219

Dear Andrey,

Current implementation of OCC optimized memory manager satisfies the requirements specified in the description, so the bug can be closed.

ilv

2012-10-25 12:25

developer   ~0021938

Allocation and deallocation of small and medium blocks works correctly. If we request to allocate block of zero size, then free it, in myFreeList adding pointer to this zero-block on zero index. It is correct, because minimum index of myFreeList is 0 and maximum index is myFreeListMax. Count of memory for myFreeList equal (myFreeListMax+1).

myFreeList = (Standard_Size **) calloc (myFreeListMax+1, sizeof(Standard_Size *));

Issue History

Date Modified Username Field Change
2006-10-12 12:44 bugmaster Assigned To bugmaster => agv
2006-10-12 12:44 bugmaster Status new => assigned
2007-02-04 18:25 abv OtherBugsDependingOnThis => 10096
2011-08-02 11:23 bugmaster Category OCCT:FDC => OCCT:Foundation Classes
2012-03-21 14:43 abv Assigned To agv => dbv
2012-03-21 14:44 abv Relationship added related to 0023033
2012-03-30 11:08 dbv Note Added: 0020219
2012-03-30 11:08 dbv Assigned To dbv => abv
2012-03-30 11:08 dbv Status assigned => resolved
2012-10-03 08:29 abv Assigned To abv => ilv
2012-10-24 17:17 abv Fixed in Version EMPTY =>
2012-10-24 17:17 abv Target Version => 6.6.0
2012-10-24 17:17 abv Description Updated
2012-10-25 12:25 ilv Note Added: 0021938
2012-10-25 12:57 abv Status resolved => closed
2012-10-25 12:57 abv Resolution open => no change required
2012-10-25 12:57 abv Target Version 6.6.0 =>