MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Related Changesets ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0030720Open CASCADE[OCCT] OCCT:Codingpublic2019-05-20 12:372019-09-29 12:36
Reportertizmaylo 
Assigned Tobugmaster 
PrioritynormalSeverityminor 
StatusverifiedResolutionfixed 
PlatformOSOS Version
Product Version[OCCT] 7.4.0 
Target Version[OCCT] 7.4.0Fixed in Version 
Summary0030720: Coding - fix HashCode() function problems that are not resolved with 30550
DescriptionThere are some problems that were not resolved with 0030550:

  • undefined behavior caused by left shift operations in TopLoc_Location::HashCode() function is not fixed (look at the places where the local variable depth is used);

  • HashCode() functions are not fixed in OCC Products;

  • HashCode() function overload for unsigned int behaves differently on 32-bit and 64-bit platforms (on 32-bit platform it is disabled via SFINAE and HashCode() function overload for std::size_t type is used because std::size_t == unsigned int).


To solve the problem with other projects it may be useful to add asserts to methods of map classes that are dealing with hash codes to check their values to be strictly one-based (not zero-based).
Steps To ReproduceNot required
TagsNo tags attached.
Test case numberNot required
Attached Files

- Relationships
child of 0030550verifiedbugmaster Community Coding - Integer overflow in Standard_CString HashCodes 

-  Notes
(0086817)
git (administrator)
2019-09-05 19:59

Branch CR30720 has been created by tizmaylo.

SHA-1: 58828d2acf8b61ec40f099a46b27b9a49b5a4f26


Detailed log of new commits:

Author: tiv
Date: Thu Sep 5 19:30:47 2019 +0300

    0030720: Coding - fix HashCode() function problems that are not resolved with 30550
    
    Undefined behavior caused by left shift operations in TopLoc_Location::HashCode() function is fixed.
    HashCode() function overload for Standard_Size type is made available only if Standard_Size and "unsigned int" are different types (it is usually true for 64-bit platforms). The overload for "unsigned int" is made simple non-templated function (so it behaves the same on 32-bit and 64-bit platforms).
(0086819)
tizmaylo (developer)
2019-09-05 20:16

Patch is ready for review (at the time of writing, the tests have not passed yet, but I hope everything will be OK): http://jenkins-test-12.nnov.opencascade.com:8080/view/CR30720-master-TIV/view/ALL/ [^]

OCCT branch: CR30720
Branch in OCCT Products: CR30720
(0086914)
bugmaster (administrator)
2019-09-06 22:09

Regressions on Products:

http://jenkins-test-12.nnov.opencascade.com/view/CR30720-master-TIV/view/COMPARE/ [^]
(0087466)
git (administrator)
2019-09-24 12:14

Branch CR30720 has been updated forcibly by tizmaylo.

SHA-1: 7d309b94bf82625152942c96202fd0ebe35cc17c
(0087488)
git (administrator)
2019-09-24 16:48

Branch CR30720 has been updated by tizmaylo.

SHA-1: 86eb424f30f5cffd39c6bdc16be633e8a8fbf2c6


Detailed log of new commits:

Author: tiv
Date: Tue Sep 24 16:39:56 2019 +0300

    # HashCode() overload for Standard_Utf32Char type is fixed to be compilable with old version of compilers (e.g. MSVS 2010).

(0087489)
git (administrator)
2019-09-24 16:48

Branch CR30720_1 has been created by tizmaylo.

SHA-1: 238bfda1dcaf1d1dfde4d29a5960212ddea36352


Detailed log of new commits:

Author: tiv
Date: Tue Sep 24 16:42:21 2019 +0300

    0030720: Coding - fix HashCode() function problems that are not resolved with 30550
    
    Undefined behavior caused by left shift operations in TopLoc_Location::HashCode() function is fixed.
    HashCode() function overload for Standard_Size type is made available only if Standard_Size and "unsigned int" are different types (it is usually true for 64-bit platforms). The overload for "unsigned int" is made simple non-templated function (so it behaves the same on 32-bit and 64-bit platforms).
    HashCode() function overload for Standard_Utf32Char type is made available only if Standard_Utf32Char and "unsigned int" are different types (it is needed for some old compilers).
(0087494)
tizmaylo (developer)
2019-09-24 18:53

Patch is ready for review: http://vm-jenkins-test-12.nnov.opencascade.com:8080/view/CR30720-master-TIV/view/ALL/ [^]

OCCT branch: CR30720
OCCT branch with squashed commits: CR30720_1
OCCT Products branch: CR30720
OCCT Products branch with squashed commits: CR30720_1
(0087495)
kgv (developer)
2019-09-24 20:34
edited on: 2019-09-24 20:35

Practically speaking, Font_BRepFont and OpenGl_Font are the only two places using Standard_Utf32Char as a key in map.
Therefore, moving hasher to dedicated structure for Standard_Utf32Char type would fix global collision of Hash/IsEqual methods.
> NCollection_DataMap<Standard_Utf32Char, Standard_Integer> myGlyphMap;
> NCollection_DataMap<Standard_Utf32Char, TopoDS_Shape> myCache;

(0087511)
bugmaster (administrator)
2019-09-25 15:56

Combination -
OCCT branch : CR30720_1
master SHA - 238bfda1dcaf1d1dfde4d29a5960212ddea36352
5f5b1aed1c6e139bbd34314eca77ae7abcd8895c
Products branch : CR30720_1 SHA - 83df4cb7aa05ca0b1f190a68462fc970ee162d17
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 16819.760000000093 / 16808.79000000008 [+0.07%]
Products
Total CPU difference: 10575.410000000034 / 10573.91000000004 [+0.01%]
Windows-64-VC14:
OCCT
Total CPU difference: 18320.0625 / 18298.78125 [+0.12%]
Products
Total CPU difference: 12486.3125 / 12507.671875 [-0.17%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
(0087615)
git (administrator)
2019-09-29 12:36

Branch CR30720 has been deleted by inv.

SHA-1: 86eb424f30f5cffd39c6bdc16be633e8a8fbf2c6
(0087616)
git (administrator)
2019-09-29 12:36

Branch CR30720_1 has been deleted by inv.

SHA-1: 238bfda1dcaf1d1dfde4d29a5960212ddea36352

- Related Changesets
occt: master 467e864a
Timestamp: 2019-09-24 13:42:21
Author: tiv
Committer: bugmaster
Details ] Diff ]
0030720: Coding - fix HashCode() function problems that are not resolved with 30550

Undefined behavior caused by left shift operations in TopLoc_Location::HashCode() function is fixed.
HashCode() function overload for Standard_Size type is made available only if Standard_Size and "unsigned int" are different types (it is usually true for 64-bit platforms). The overload for "unsigned int" is made simple non-templated function (so it behaves the same on 32-bit and 64-bit platforms).
HashCode() function overload for Standard_Utf32Char type is made available only if Standard_Utf32Char and "unsigned int" are different types (it is needed for some old compilers).
mod - src/Standard/Standard_Integer.hxx Diff ] File ]
mod - src/Standard/Standard_Size.hxx Diff ] File ]
mod - src/TopLoc/TopLoc_Location.cxx Diff ] File ]

- Issue History
Date Modified Username Field Change
2019-05-20 12:37 tizmaylo New Issue
2019-05-20 12:37 tizmaylo Assigned To => kgv
2019-05-20 12:42 kgv Relationship added child of 0030550
2019-05-20 12:43 kgv Description Updated View Revisions
2019-05-21 18:41 tizmaylo Description Updated View Revisions
2019-09-04 17:11 kgv Product Version => 7.4.0
2019-09-04 17:11 kgv Target Version 7.4.0 => 7.5.0*
2019-09-04 17:33 kgv Assigned To kgv => tizmaylo
2019-09-04 17:33 kgv Status new => assigned
2019-09-04 17:33 kgv Target Version 7.5.0* => 7.4.0
2019-09-05 19:59 git Note Added: 0086817
2019-09-05 20:16 tizmaylo Note Added: 0086819
2019-09-05 20:18 tizmaylo Assigned To tizmaylo => abv
2019-09-05 20:18 tizmaylo Status assigned => resolved
2019-09-05 20:18 tizmaylo Steps to Reproduce Updated View Revisions
2019-09-06 11:12 kgv Assigned To abv => bugmaster
2019-09-06 11:12 kgv Status resolved => reviewed
2019-09-06 22:09 bugmaster Note Added: 0086914
2019-09-06 22:09 bugmaster Assigned To bugmaster => tizmaylo
2019-09-06 22:09 bugmaster Status reviewed => assigned
2019-09-17 06:50 abv Target Version 7.4.0 => 7.5.0*
2019-09-24 12:14 git Note Added: 0087466
2019-09-24 16:48 git Note Added: 0087488
2019-09-24 16:48 git Note Added: 0087489
2019-09-24 18:53 tizmaylo Note Added: 0087494
2019-09-24 18:54 tizmaylo Assigned To tizmaylo => kgv
2019-09-24 18:54 tizmaylo Status assigned => resolved
2019-09-24 20:34 kgv Note Added: 0087495
2019-09-24 20:34 kgv Assigned To kgv => bugmaster
2019-09-24 20:34 kgv Status resolved => reviewed
2019-09-24 20:34 kgv Target Version 7.5.0* => 7.4.0
2019-09-24 20:35 kgv Note Edited: 0087495 View Revisions
2019-09-25 15:53 bugmaster Test case number => Not required
2019-09-25 15:56 bugmaster Note Added: 0087511
2019-09-25 15:56 bugmaster Status reviewed => tested
2019-09-29 12:19 bugmaster Changeset attached => occt master 467e864a
2019-09-29 12:19 bugmaster Status tested => verified
2019-09-29 12:19 bugmaster Resolution open => fixed
2019-09-29 12:36 git Note Added: 0087615
2019-09-29 12:36 git Note Added: 0087616


Copyright © 2000 - 2019 MantisBT Team
Powered by Mantis Bugtracker