View Issue Details

IDProjectCategoryView StatusLast Update
0022749CommunityOCCT:Foundation Classespublic2012-03-29 17:26
ReporterszyAssigned Tobugmaster  
PrioritynormalSeveritymajor 
Status closedResolutionfixed 
PlatformAOSL 
Product Version6.5.1 
Target Version6.5.3Fixed in Version6.5.3 
Summary0022749: Segfault in HashCode() of Standard_Transient
DescriptionPost 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).
Steps To ReproduceDraw 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);
TagsNo tags attached.
Test case numbertest case is not required

Attached Files

  • fix-hashcode.patch (1,535 bytes)

Activities

szy

2011-10-04 17:45

manager  

fix-hashcode.patch (1,535 bytes)

dbv

2012-01-20 15:00

developer   ~0019202

Patch applied.

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

Dear Andrey,
Please review.

abv

2012-01-23 09:33

manager   ~0019221

No remarks, please test

aan

2012-01-27 11:22

tester   ~0019277

Last edited: 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

aan

2012-02-02 12:52

tester   ~0019349

Last edited: 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

dbv

2012-02-02 13:27

developer   ~0019351

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.

abv

2012-02-02 13:39

manager   ~0019355

Last edited: 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.

dbv

2012-02-06 12:18

developer   ~0019402

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.

abv

2012-02-06 12:34

manager   ~0019405

No remarks, please test

aan

2012-02-08 16:10

tester   ~0019465

Last edited: 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 : -----------------------------------------------------------------

dbv

2012-02-09 11:07

developer   ~0019485

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.

dbv

2012-02-10 17:36

developer   ~0019520

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.

aan

2012-02-14 14:19

tester   ~0019553

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

bugmaster

2012-02-17 15:57

administrator   ~0019632

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

Related Changesets

occt: master ec6a1aa7

2012-02-17 11:40:25

dbv


Committer: bugmaster Details Diff
0022749: Segfault in HashCode() of Standard_Transient Affected Issues
0022749
mod - src/Graphic2d/Graphic2d_Buffer.cxx Diff File
mod - src/Standard/Standard_Persistent.cxx Diff File
mod - src/Standard/Standard_Persistent_proto.hxx Diff File
mod - src/Standard/Standard_Transient.cxx Diff File
mod - src/Standard/Standard_Transient_proto.hxx Diff File
mod - src/TopLoc/TopLoc_Location.cxx Diff File
mod - src/WNT/WNT_WDriver.cxx Diff File
mod - src/Xw/Xw_Driver.cxx Diff File

Issue History

Date Modified Username Field Change
2011-10-04 17:45 szy New Issue
2011-10-04 17:45 szy Assigned To => abv
2011-10-04 17:45 szy File Added: fix-hashcode.patch
2011-12-01 10:04 abv Assigned To abv => dbv
2011-12-01 10:04 abv Status new => assigned
2012-01-20 15:00 dbv Note Added: 0019202
2012-01-20 15:00 dbv Assigned To dbv => abv
2012-01-20 15:00 dbv Status assigned => resolved
2012-01-23 09:33 abv Note Added: 0019221
2012-01-23 09:33 abv Status resolved => reviewed
2012-01-27 11:22 aan Note Added: 0019277
2012-01-27 11:23 aan Note Edited: 0019277
2012-01-27 11:23 aan Assigned To abv => dbv
2012-01-27 11:23 aan Status reviewed => assigned
2012-01-27 16:01 aan Test case number => chl 934 P3
2012-01-27 16:01 aan File Added: P3
2012-01-27 16:03 aan File Deleted: P3
2012-01-27 16:03 aan File Added: P3
2012-01-27 16:15 aan File Deleted: P3
2012-01-27 16:16 aan File Added: P3
2012-02-02 12:52 aan Note Added: 0019349
2012-02-02 12:53 aan Status assigned => feedback
2012-02-02 12:53 aan Status feedback => reviewed
2012-02-02 12:53 aan Status reviewed => tested
2012-02-02 12:54 aan Note Edited: 0019349
2012-02-02 13:12 aan Note Edited: 0019349
2012-02-02 13:16 dbv Status tested => assigned
2012-02-02 13:27 dbv Note Added: 0019351
2012-02-02 13:27 dbv Assigned To dbv => abv
2012-02-02 13:27 dbv Status assigned => resolved
2012-02-02 13:39 abv Note Added: 0019355
2012-02-02 13:39 abv Assigned To abv => dbv
2012-02-02 13:39 abv Status resolved => assigned
2012-02-06 12:18 dbv Note Added: 0019402
2012-02-06 12:18 dbv Assigned To dbv => abv
2012-02-06 12:18 dbv Status assigned => resolved
2012-02-06 12:34 abv Note Added: 0019405
2012-02-06 12:34 abv Assigned To abv => dbv
2012-02-06 12:34 abv Status resolved => reviewed
2012-02-08 16:10 aan Note Added: 0019465
2012-02-08 16:10 aan Status reviewed => assigned
2012-02-08 17:58 aan Note Edited: 0019465
2012-02-09 09:02 abv Note Edited: 0019355
2012-02-09 11:07 dbv Note Added: 0019485
2012-02-09 11:07 dbv Assigned To dbv => abv
2012-02-09 11:07 dbv Status assigned => resolved
2012-02-09 12:18 dbv Assigned To abv => dbv
2012-02-09 12:18 dbv Status resolved => reviewed
2012-02-09 12:35 dbv Status reviewed => assigned
2012-02-10 17:33 dbv Status assigned => resolved
2012-02-10 17:36 dbv Note Added: 0019520
2012-02-10 17:36 dbv Status resolved => reviewed
2012-02-14 13:21 mkv Assigned To dbv => aan
2012-02-14 14:16 aan File Deleted: P3
2012-02-14 14:16 aan Test case number chl 934 P3 => test case is not required
2012-02-14 14:19 aan Note Added: 0019553
2012-02-14 14:46 aan Status reviewed => tested
2012-02-17 15:57 bugmaster Note Added: 0019632
2012-02-17 15:57 bugmaster Status tested => verified
2012-02-17 15:57 bugmaster Resolution open => fixed
2012-02-17 15:57 bugmaster Assigned To aan => dbv
2012-03-29 17:26 bugmaster Changeset attached => occt master ec6a1aa7