MantisBT - Community
View Issue Details
0022749Community[OCCT] OCCT:Foundation Classespublic2011-10-04 17:452012-03-29 17:26
szy 
bugmaster 
normalmajor 
closedfixed 
ALL
[OCCT] 6.5.1 
[OCCT] 6.5.3[OCCT] 6.5.3 
test case is not required
0022749: Segfault in HashCode() of Standard_Transient
Post from the Forum - http://www.opencascade.org/org/forum/thread_21955/ [^]
" The code below segfaults on Linux when MMGT_OPT is set to 0 or 2:

#include <Standard_Transient.hxx>
#include <iostream>

int main(int argc, char **argv) {
Standard_Transient s;
Standard_Integer i = s.HashCode(1000);
std::cout << i << std::endl;
return 0;
}

The current implementation calls HashCode(Handle_Standard_Transient,Standard_Integer)
due to implicit conversion operator. But if object is allocated on the stack,
a segmentation fault occurs when the Handle_Standard_Transient temporary object
is deleted. This happens if MMGT_OPT is set and different from 1.

Implicit conversions should really be forbidden in order to avoid those subtle bugs."

Patch is attached (for information).
Draw Command:
static int TestHash (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
 Standard_Transient s;
 Standard_Integer i = s.HashCode(1000);
 std::cout << i << std::endl;
 return 0;
}

 theCommands.Add ("TestHash",
                  "TestHash \n",
                  __FILE__, TestHash, g);
No tags attached.
patch fix-hashcode.patch (1,535) 2011-10-04 17:45
https://tracker.dev.opencascade.org/
Issue History
2011-10-04 17:45szyNew Issue
2011-10-04 17:45szyAssigned To => abv
2011-10-04 17:45szyFile Added: fix-hashcode.patch
2011-12-01 10:04abvAssigned Toabv => dbv
2011-12-01 10:04abvStatusnew => assigned
2012-01-20 15:00dbvNote Added: 0019202
2012-01-20 15:00dbvAssigned Todbv => abv
2012-01-20 15:00dbvStatusassigned => resolved
2012-01-23 09:33abvNote Added: 0019221
2012-01-23 09:33abvStatusresolved => reviewed
2012-01-27 11:22aanNote Added: 0019277
2012-01-27 11:23aanNote Edited: 0019277bug_revision_view_page.php?bugnote_id=19277#r3326
2012-01-27 11:23aanAssigned Toabv => dbv
2012-01-27 11:23aanStatusreviewed => assigned
2012-01-27 16:01aanTest case number => chl 934 P3
2012-01-27 16:01aanFile Added: P3
2012-01-27 16:03aanFile Deleted: P3
2012-01-27 16:03aanFile Added: P3
2012-01-27 16:15aanFile Deleted: P3
2012-01-27 16:16aanFile Added: P3
2012-02-02 12:52aanNote Added: 0019349
2012-02-02 12:53aanStatusassigned => feedback
2012-02-02 12:53aanStatusfeedback => reviewed
2012-02-02 12:53aanStatusreviewed => tested
2012-02-02 12:54aanNote Edited: 0019349bug_revision_view_page.php?bugnote_id=19349#r3364
2012-02-02 13:12aanNote Edited: 0019349bug_revision_view_page.php?bugnote_id=19349#r3365
2012-02-02 13:16dbvStatustested => assigned
2012-02-02 13:27dbvNote Added: 0019351
2012-02-02 13:27dbvAssigned Todbv => abv
2012-02-02 13:27dbvStatusassigned => resolved
2012-02-02 13:39abvNote Added: 0019355
2012-02-02 13:39abvAssigned Toabv => dbv
2012-02-02 13:39abvStatusresolved => assigned
2012-02-06 12:18dbvNote Added: 0019402
2012-02-06 12:18dbvAssigned Todbv => abv
2012-02-06 12:18dbvStatusassigned => resolved
2012-02-06 12:34abvNote Added: 0019405
2012-02-06 12:34abvAssigned Toabv => dbv
2012-02-06 12:34abvStatusresolved => reviewed
2012-02-08 16:10aanNote Added: 0019465
2012-02-08 16:10aanStatusreviewed => assigned
2012-02-08 17:58aanNote Edited: 0019465bug_revision_view_page.php?bugnote_id=19465#r3416
2012-02-09 09:02abvNote Edited: 0019355bug_revision_view_page.php?bugnote_id=19355#r3418
2012-02-09 11:07dbvNote Added: 0019485
2012-02-09 11:07dbvAssigned Todbv => abv
2012-02-09 11:07dbvStatusassigned => resolved
2012-02-09 12:18dbvAssigned Toabv => dbv
2012-02-09 12:18dbvStatusresolved => reviewed
2012-02-09 12:35dbvStatusreviewed => assigned
2012-02-10 17:33dbvStatusassigned => resolved
2012-02-10 17:36dbvNote Added: 0019520
2012-02-10 17:36dbvStatusresolved => reviewed
2012-02-14 13:21mkvAssigned Todbv => aan
2012-02-14 14:16aanFile Deleted: P3
2012-02-14 14:16aanTest case numberchl 934 P3 => test case is not required
2012-02-14 14:19aanNote Added: 0019553
2012-02-14 14:46aanStatusreviewed => tested
2012-02-17 15:57bugmasterNote Added: 0019632
2012-02-17 15:57bugmasterStatustested => verified
2012-02-17 15:57bugmasterResolutionopen => fixed
2012-02-17 15:57bugmasterAssigned Toaan => dbv
2012-03-29 17:26bugmasterChangeset attached => occt master ec6a1aa7

Notes
(0019202)
dbv   
2012-01-20 15:00   
Patch applied.

Branch http://svn/svn/occt/branches/OCC22749 [^] is ready to be reviewed.

Dear Andrey,
Please review.
(0019221)
abv   
2012-01-23 09:33   
No remarks, please test
(0019277)
aan   
2012-01-27 11:22   
(edited on: 2012-01-27 11:23)
Dear BugMaster,
Workbench KAS:dev:aan-OCC22749-occt was created from SVN branch http://svn/svn/occt/branches/OCC22749 [^]
(and aan-OCC22749-products from trunk) and compiled on Linux platform.

Test for this fix is chl 934 P3. It's OK.

Workbench KAS:dev: aan-OCC22749-products was tested with MMGT_OPT=0

There are following regressions in aan-OCC22749-products regarding to KAS:dev:products-20120120-opt

chl 928 R1
chl 936 G9

See results in /QADisk/occttests/results/KAS/dev/ aan-OCC22749-products_26012012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120120-opt_20012012/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 [^]

(0019349)
aan   
2012-02-02 12:52   
(edited on: 2012-02-02 13:12)
Dear BugMaster,
Workbench KAS:dev:aan-OCC22749-occt was created from SVN branch http://svn/svn/occt/branches/OCC22749 [^]
(and aan-OCC22749-products from trunk) and compiled on Linux platform.

Test for this fix is chl 934 P3. It's OK.

Workbench KAS:dev: aan-OCC22749-products was tested with MMGT_OPT=0

There are not regressions in aan-OCC22749-products regarding to KAS:dev:products-20120120-opt

See results in /QADisk/occttests/results/KAS/dev/ aan-OCC22749-products_26012012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120120-opt_20012012/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 [^]

(0019351)
dbv   
2012-02-02 13:27   
Also added fix to the Standard_Persistent::HashCode function.

Branch http://svn/svn/occt/branches/OCC22749 [^] is ready to be reviewed.

Dear Andrey,
Please review.
(0019355)
abv   
2012-02-02 13:39   
(edited on: 2012-02-09 09:02)
Sorry, after some thinking I got to different idea: we should not have HashCode for Standard_Transient and Standard_Persistent at all. By its nature, the hash code should be computed from content of the object. For Handle objects, it is thus correct to compute has code from the address of the referred object. However, for the object itself it is senseless to compute hash code from its address.

Thus I suggest we remove these functions and check if they are needed at all anywhere.

(0019402)
dbv   
2012-02-06 12:18   
HashCode function has been removed from Standard_Transient and Standard_Persistent and all calls has been replaced with HashCode from Standard_HashCode.

Branch http://svn/svn/occt/branches/OCC22749 [^] is ready to be reviewed.

Dear Andrey,
Please review.
(0019405)
abv   
2012-02-06 12:34   
No remarks, please test
(0019465)
aan   
2012-02-08 16:10   
(edited on: 2012-02-08 17:58)
Info : -------> Xw_Driver.cxx
Error : Errors occured in Shell
/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx: In member function 'virtual Standard_Boolean Xw_Driver::IsKnownImage(const Handle_Standard_Transient&)':

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx:868: error: 'class Standard_Transient' has no member named 'HashCode'

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx: In member function 'virtual void Xw_Driver::ClearImage(const Handle_Standard_Transient&)':

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx:902: error: 'class Standard_Transient' has no member named 'HashCode'

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx: In member function 'virtual void Xw_Driver::DrawImage(const Handle_Standard_Transient&, Standard_ShortReal, Standard_ShortReal)':

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx:924: error: 'class Standard_Transient' has no member named 'HashCode'

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx: In member function 'virtual void Xw_Driver::FillAndDrawImage(const Handle_Standard_Transient&, Standard_ShortReal, Standard_ShortReal, Standard_Integer, Standard_Integer, void*)':

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx:976: error: 'class Standard_Transient' has no member named 'HashCode'

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx: In member function 'virtual void Xw_Driver::FillAndDrawImage(const Handle_Standard_Transient&, Standard_ShortReal, Standard_ShortReal, Standard_Integer, Standard_Integer, Standard_Integer, void*)':

/dn47/KAS/dev/aan-OCC22749-occt/src/Xw/Xw_Driver.cxx:1095: error: 'class Standard_Transient' has no member named 'HashCode'

Error : Failed : Xw_Driver.cxx
Info : ----------------------- Compilation Report -----------------------
Info : Failed : :KAS:dev:aan-OCC22749-occt:Xw:source:Xw_Driver.cxx
Info : -----------------------------------------------------------------
Error : Failed during execution
Info : Step obj.comp
Error : Step obj.comp failed
Error : Step obj.idep not done : almost Xw:obj.comp failed
Info : ------------------ Process report ------------------
Info : Failed Xw (obj.comp obj.idep )
Info : ----------------------------------------------------

Info : ----------------------- Compilation Report -----------------------
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFAlgo:source:OMFAlgo_Intersect.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFAlgo:source:OMFAlgo_MeshIntersect.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFAlgo:source:OMFAlgo_IntersectOnTree.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFAlgo:source:OMFAlgo_LineIntersect.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFAlgo:source:OMFAlgo_PlaneIntersect.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFBool:source:OMFBool_BooleanOperation.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFBool:source:OMFBool_SplitElement.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFVS:source:OMFVS_VisibleFilter.cxx
Info : Failed : :KAS:dev:aan-OCC22749-products:OMFTest:source:OMFTest_ModelCommands.cxx
Info : -----------------------------------------------------------------

(0019485)
dbv   
2012-02-09 11:07   
HasCode functions in src/Xw/Xw_Driver.cxx have been replaced

Branch http://svn/svn/occt/branches/OCC22749 [^] is ready to be reviewed.

Dear Andrey,
Please review.
(0019520)
dbv   
2012-02-10 17:36   
Products part has been updated

Branches
http://svn/svn/occt/branches/OCC22749 [^]
http://svn/svn/occt-products/branches/OCC22749 [^]
are ready for testing.

Please test.
(0019553)
aan   
2012-02-14 14:19   
Dear BugMaster,
Workbench KAS:dev:aan-OCC22749-occt was created from SVN branch http://svn/svn/occt/branches/OCC22749 [^]
(and aan-OCC22749-products was created from http://svn/svn/occt-products/branches/OCC22749 [^] ) and compiled on Linux platform.

Workbench KAS:dev:aan-OCC22749-products was tested with MMGT_OPT=0

There are not regressions in aan-OCC22749-products regarding to KAS:dev:products-20120210-opt

See results in /QADisk/occttests/results/KAS/dev/aan-OCC22749-products_13022012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120210-opt_10022012/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 [^]
(0019632)
bugmaster   
2012-02-17 15:57   
Integration into trunk of occt repository

Date: 2012-02-17 15:40:25 +0400 (Fri, 17 Feb 2012)
New Revision: 10506

Modified:
   trunk/src/Graphic2d/Graphic2d_Buffer.cxx
   trunk/src/Standard/Standard_Persistent.cxx
   trunk/src/Standard/Standard_Persistent_proto.hxx
   trunk/src/Standard/Standard_Transient.cxx
   trunk/src/Standard/Standard_Transient_proto.hxx
   trunk/src/TopLoc/TopLoc_Location.cxx
   trunk/src/WNT/WNT_WDriver.cxx
   trunk/src/Xw/Xw_Driver.cxx

Integration into trunk of occt-products repository

Date: 2012-02-17 15:53:07 +0400 (Fri, 17 Feb 2012)
New Revision: 18551

Modified:
   trunk/src/OMFAlgo/OMFAlgo_Intersect.lxx