MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0022293Community[OCCT] OCCT:Foundation Classespublic2011-02-22 12:152012-03-29 17:26
Reporterszy 
Assigned Tobugmaster 
PrioritynormalSeveritytrivial 
StatusclosedResolutionfixed 
PlatformOSAllOS Version
Product Version 
Target Version[OCCT] 6.5.2Fixed in Version[OCCT] 6.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 Files7z file icon NCollection_IncAllocator.7z (2,187 bytes) 2011-04-29 16:24

- Relationships

-  Notes
(0016918)
vsv (developer)
2011-04-29 16:26

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.
(0017852)
bugmaster (administrator)
2011-07-29 13:21

Kilril,
SVN branch http://svn/svn/occt/branches/OCC22293 [^]
has been created and ready to be revised
(0018017)
kgv (developer)
2011-08-23 15:06

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.
(0018046)
mkv (tester)
2011-08-31 18:54
edited on: 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 [^]

(0018047)
bugmaster (administrator)
2011-08-31 19:36

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
Timestamp: 2011-08-31 15:35:11
Author: kgv
Committer: bugmaster
Details ] Diff ]
0022293: Incorrect memory allocation for NCollection_IncAllocator on Windows 64 bit
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 View Revisions
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 View Revisions
2011-12-16 10:05 mkk Relationship added has duplicate 0022151
2012-03-29 17:26 bugmaster Changeset attached => occt master c99551fa


Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker