View Issue Details

IDProjectCategoryView StatusLast Update
0022293CommunityOCCT:Foundation Classespublic2012-03-29 17:26
Reporterszy Assigned Tobugmaster  
PrioritynormalSeveritytrivial 
Status closedResolutionfixed 
OSAll 
Target Version6.5.2Fixed in Version6.5.2 
Summary0022293: Incorrect memory allocation for NCollection_IncAllocator on Windows 64 bit
DescriptionPost 19966:
===========
Microsoft's Visual C++ compiler uses the LLP64 model. So the pointer size is 8
bytes and long int is only 4 bytes.
The type cast to (unsigned long) in line 15 of NCollection_IncAllocator.cxx

#define IMEM_ALIGN(_addr) (sizeof(aligned_t)* IMEM_SIZE((unsigned long)(_addr)))

therefore truncates the address (_addr) to 4 bytes (at least on Windows platforms).
If a new allocated block has an address returned by malloc exceeding 4 bytes
this results in a wrong pointer returned by
NCollection_IncAllocator::allocateNewBlock and
NCollection_IncAllocator::Allocate. This can cause an access violation in the
following.
I figured this out when I received some access violation crashes during meshing.

As a fix I suggest casting to size_t instead:

#define IMEM_ALIGN(_addr) (sizeof(aligned_t)* IMEM_SIZE((size_t)(_addr)))
===========================================================================
MSDN:
"In the LLP64 data model, only pointers expand to 64 bits; all other basic data
types (integer and long) remain 32 bits in length".
TagsNo tags attached.
Test case numberTest case is not required

Attached Files

  • NCollection_IncAllocator.7z (2,187 bytes)

Activities

2011-04-29 16:24

 

NCollection_IncAllocator.7z (2,187 bytes)

vsv

2011-04-29 16:26

developer   ~0016918

The remark seems reasonable. It was checked on win32 - problems were not
found. File with fix is attached. It has to be checked on all platforms
supported by OCCT.

bugmaster

2011-07-29 13:21

administrator   ~0017852

Kilril,
SVN branch http://svn/svn/occt/branches/OCC22293
has been created and ready to be revised

kgv

2011-08-23 15:06

developer   ~0018017

The bug branch was reviewed. Patch was applied incorrectly - that was fixed already. Also applied patch to IMEM_FREE macro which also uses wrong type (unsigned int) however this place can cause error only in future when 64bit computations come really far from now.

Branch is ready for testing.

mkv

2011-08-31 18:54

tester   ~0018046

Last edited: 2011-11-25 11:51

Dear BugMaster,
Workbench KAS:dev:mkv-OCC22293-occt has been created from SVN branch http://svn/svn/occt/branches/OCC22293
(and mkv-OCC22293-products from trank) and compiled on Linux platform.

There are not regressions in mkv-OCC22293-products regarding to KAS:dev:products-20110821-opt

See results in /QADisk/occttests/tests/KAS/dev/mkv-OCC22293-products_30082011/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20110821-opt_22082011/lin
See test cases in /QADisk/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions
http://doc/doku.php?id=occt.certification

bugmaster

2011-08-31 19:36

administrator   ~0018047

Fix has been integrated to occt repository

Date: 2011-08-31 19:35:11 +0400 (Wed, 31 Aug 2011)
New Revision: 8929

Modified:
   trunk/src/NCollection/NCollection_IncAllocator.cxx

Related Changesets

occt: master c99551fa

2011-08-31 15:35:11

kgv


Committer: bugmaster Details Diff
0022293: Incorrect memory allocation for NCollection_IncAllocator on Windows 64 bit Affected Issues
0022293
mod - src/NCollection/NCollection_IncAllocator.cxx Diff File

Issue History

Date Modified Username Field Change
2011-04-06 18:31 bugmaster Status closed => assigned
2011-04-06 18:31 bugmaster Resolution suspended => @0@
2011-04-06 19:01 bugmaster Assigned To bugmaster => szy
2011-04-28 17:58 szy Assigned To szy => vsv
2011-04-29 16:26 vsv Status assigned => resolved
2011-07-29 13:21 bugmaster Note Added: 0017852
2011-07-29 13:21 bugmaster Assigned To vsv => kgv
2011-07-29 13:21 bugmaster Status resolved => assigned
2011-07-29 13:23 bugmaster Status assigned => resolved
2011-07-29 13:23 bugmaster Fixed in Version EMPTY =>
2011-07-29 13:23 bugmaster Description Updated
2011-08-02 11:23 bugmaster Category OCCT:FDC => OCCT:Foundation Classes
2011-08-23 15:06 kgv Note Added: 0018017
2011-08-23 15:06 kgv Status resolved => reviewed
2011-08-23 15:07 kgv Assigned To kgv => bugmaster
2011-08-31 11:10 mkv Test case number => Test case is not required
2011-08-31 18:54 mkv Note Added: 0018046
2011-08-31 18:54 mkv Status reviewed => tested
2011-08-31 19:36 bugmaster Note Added: 0018047
2011-08-31 19:36 bugmaster Status tested => verified
2011-08-31 19:36 bugmaster Assigned To bugmaster => kgv
2011-09-20 17:29 szy Target Version => 6.5.2
2011-11-25 11:51 szy Note Edited: 0018046
2012-03-29 17:26 bugmaster Changeset attached => occt master c99551fa