View Issue Details

IDProjectCategoryView StatusLast Update
0030562CommunityOCCT:Codingpublic2019-03-19 10:33
Reportergalbramc Assigned Toapn  
PrioritynormalSeveritycrash 
Status closedResolutionfixed 
Product Version5.2.2 
Target Version7.4.0Fixed in Version7.4.0 
Summary0030562: Coding - TopOpeBRepBuild_Builder use of null pointer
DescriptionI got the following error running with OCCT 7.3.0 compiled with -fsanitize=undefined:

src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx:197:63: runtime error: member call on null pointer of type 'struct TopOpeBRepDS_HDataStructure'
src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx:197:63: runtime error: member access within null pointer of type 'struct TopOpeBRepDS_HDataStructure'

I found that the following patch resolves the issue:


Index: src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx
===================================================================
--- src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx (revision 1)
+++ src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx (working copy)
@@ -194,27 +194,30 @@
 //=======================================================================
 void TopOpeBRepBuild_Builder::Clear()
 {
- const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
- TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it;
- for (it.Initialize(mySplitOUT); it.More(); it.Next()) {
- const TopoDS_Shape& e = it.Key();
- if ( e.ShapeType() == TopAbs_EDGE ) {
- Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
- if (!isse) mySplitOUT.ChangeFind(e).Clear();
+ if (!myDataStructure.IsNull())
+ {
+ const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();
+ TopOpeBRepDS_DataMapIteratorOfDataMapOfShapeListOfShapeOn1State it;
+ for (it.Initialize(mySplitOUT); it.More(); it.Next()) {
+ const TopoDS_Shape& e = it.Key();
+ if ( e.ShapeType() == TopAbs_EDGE ) {
+ Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
+ if (!isse) mySplitOUT.ChangeFind(e).Clear();
+ }
     }
- }
- for (it.Initialize(mySplitIN); it.More(); it.Next()) {
- const TopoDS_Shape& e = it.Key();
- if ( e.ShapeType() == TopAbs_EDGE ) {
- Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
- if (!isse) mySplitIN.ChangeFind(e).Clear();
+ for (it.Initialize(mySplitIN); it.More(); it.Next()) {
+ const TopoDS_Shape& e = it.Key();
+ if ( e.ShapeType() == TopAbs_EDGE ) {
+ Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
+ if (!isse) mySplitIN.ChangeFind(e).Clear();
+ }
     }
- }
- for (it.Initialize(mySplitON); it.More(); it.Next()) {
- const TopoDS_Shape& e = it.Key();
- if ( e.ShapeType() == TopAbs_EDGE ) {
- Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
- if (!isse) mySplitON.ChangeFind(e).Clear();
+ for (it.Initialize(mySplitON); it.More(); it.Next()) {
+ const TopoDS_Shape& e = it.Key();
+ if ( e.ShapeType() == TopAbs_EDGE ) {
+ Standard_Boolean isse = BDS.IsSectionEdge(TopoDS::Edge(e));
+ if (!isse) mySplitON.ChangeFind(e).Clear();
+ }
     }
   }
   myMergedOUT.Clear();
  

I understand that TopOpe* packages are deprecated, and we plan on moving away from using them.
Steps To ReproduceCompile OCCT 7.3.0 with -fsanitize=undefined and run the test suite.

Test case: bugs/vis/bug331_1.
TagsNo tags attached.
Test case numberNot needed

Relationships

child of 0030557 newdpasukhi Open CASCADE Coding - eliminate errors reported by -fsanitize 

Activities

git

2019-03-12 20:28

administrator   ~0082883

Branch CR30562 has been created by kgv.

SHA-1: 560f2083170d964fd9a340eceb2c2c438637261b


Detailed log of new commits:

Author: kgv
Date: Tue Mar 12 20:22:26 2019 +0300

    0030562: Coding - TopOpeBRepBuild_Builder use of null pointer
    
    TopOpeBRepBuild_Builder::Clear() - added NULL check.

kgv

2019-03-12 20:30

developer   ~0082884

Note that you can prepare patches directly for git:
https://dev.opencascade.org/index.php?q=home/get_involved

galbramc

2019-03-12 20:36

reporter   ~0082885

I'm not sure I can get my organization to sign the agreement to get access to the repo...

kgv

2019-03-13 09:59

developer   ~0082895

Please raise the patch.

Tested within CR30564:
http://jenkins-test-12.nnov.opencascade.com:8080/view/CR30564-master-KGV/view/COMPARE/

apn

2019-03-13 11:49

administrator   ~0082905

Combination -
OCCT branch : CR30564
master SHA - ff1a9501d05da740074577bad046435d00fe4482
d67d4b811012eef8913d3c535c29654d0acf3c4c
Products branch : master SHA - 19cf12d4f918562ea1456aa224c6f7a64b9c4ad7
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: 16615.46999999998 / 16599.24999999996 [+0.10%]
Products
Total CPU difference: 9089.820000000022 / 9092.71000000004 [-0.03%]
Windows-64-VC14:
OCCT
Total CPU difference: 18003.609375 / 17985.28125 [+0.10%]
Products
Total CPU difference: 10497.203125 / 10460.953125 [+0.35%]

Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2019-03-19 10:33

administrator   ~0083085

Branch CR30562 has been deleted by inv.

SHA-1: 560f2083170d964fd9a340eceb2c2c438637261b

Related Changesets

occt: master a7fd4b1b

2019-03-12 17:22:26

kgv


Committer: apn Details Diff
0030562: Coding - TopOpeBRepBuild_Builder use of null pointer

TopOpeBRepBuild_Builder::Clear() - added NULL check.
Affected Issues
0030562
mod - src/TopOpeBRepBuild/TopOpeBRepBuild_Builder.cxx Diff File

Issue History

Date Modified Username Field Change
2019-03-12 19:35 galbramc New Issue
2019-03-12 19:35 galbramc Assigned To => kgv
2019-03-12 19:47 kgv Relationship added child of 0030557
2019-03-12 20:28 git Note Added: 0082883
2019-03-12 20:30 kgv Note Added: 0082884
2019-03-12 20:36 galbramc Note Added: 0082885
2019-03-13 09:59 kgv Note Added: 0082895
2019-03-13 09:59 kgv Assigned To kgv => bugmaster
2019-03-13 09:59 kgv Status new => resolved
2019-03-13 09:59 kgv Product Version 7.3.0 => 5.2.2
2019-03-13 09:59 kgv Target Version => 7.4.0
2019-03-13 09:59 kgv Status resolved => reviewed
2019-03-13 11:49 apn Test case number => Not needed
2019-03-13 11:49 apn Note Added: 0082905
2019-03-13 11:49 apn Status reviewed => tested
2019-03-15 18:09 kgv Steps to Reproduce Updated
2019-03-17 15:40 apn Changeset attached => occt master a7fd4b1b
2019-03-17 15:40 apn Assigned To bugmaster => apn
2019-03-17 15:40 apn Status tested => verified
2019-03-17 15:40 apn Resolution open => fixed
2019-03-19 10:33 git Note Added: 0083085