View Issue Details

IDProjectCategoryView StatusLast Update
0030565CommunityOCCT:Codingpublic2019-03-26 11:13
Reportergalbramc Assigned Tobugmaster  
Status closedResolutionfixed 
Product Version7.3.0 
Target Version7.4.0Fixed in Version7.4.0 
Summary0030565: Coding - Approx_SweepApproximation call on null pointer
DescriptionI compiled OCCT with the -fsanitize=undefined flag and got the following errors:

src/Approx/Approx_SweepApproximation.cxx:179:31: runtime error: member call on null pointer of type 'struct TColgp_HArray1OfVec2d'
src/Approx/Approx_SweepApproximation.cxx:179:31: runtime error: member access within null pointer of type 'struct TColgp_HArray1OfVec2d'

This is a problem when Num2DSS==0 the arrays:

 if (Num2DSS>0) {
   myPoles2d = new (TColgp_HArray1OfPnt2d)(1, Num2DSS);
   myDPoles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
   myD2Poles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
   COnSurfErr = new (TColStd_HArray1OfReal)(1, Num2DSS);

which are then used on line 179. This fix avoids the null pointer:

 myPoles2d = new (TColgp_HArray1OfPnt2d)(1, std::max(Num2DSS,1));
 myDPoles2d = new (TColgp_HArray1OfVec2d)(1, std::max(Num2DSS,1));
 myD2Poles2d = new (TColgp_HArray1OfVec2d)(1, std::max(Num2DSS,1));
 COnSurfErr = new (TColStd_HArray1OfReal)(1, std::max(Num2DSS,1));

but may not be the right solution.
Steps To ReproduceCompile OCCT with a g++ newer than 4.9 with the -fsanitize=undefined compiler flag and run the test suite.
TagsNo tags attached.
Test case numberNot needed


related to 0030582 closedapn Open CASCADE Coding - avoid defining references to properties of NULL objects 
child of 0030557 newdpasukhi Open CASCADE Coding - eliminate errors reported by -fsanitize 



2019-03-25 14:22

developer   ~0083224

Should be fixed by 0030582.
Please check, if possible.


2019-03-25 20:23

reporter   ~0083226

This will be tricky for me to check as there are a large number of changes. I could try to put together an example for you if you would like?


2019-03-26 05:06

reporter   ~0083227

As best as I can tell it looks like the fix in 0030582 should resolve this problem.


2019-03-26 08:35

developer   ~0083228

Dear bugmaster,

please switch this bug to VERIFIED (fixed in scope of 0030582).

Issue History

Date Modified Username Field Change
2019-03-13 04:44 galbramc New Issue
2019-03-13 04:44 galbramc Assigned To => kgv
2019-03-13 07:43 kgv Relationship added child of 0030557
2019-03-25 14:21 kgv Relationship added related to 0030582
2019-03-25 14:22 kgv Note Added: 0083224
2019-03-25 14:22 kgv Assigned To kgv => galbramc
2019-03-25 14:22 kgv Status new => feedback
2019-03-25 14:22 kgv Target Version => 7.4.0
2019-03-25 20:23 galbramc Note Added: 0083226
2019-03-26 05:06 galbramc Note Added: 0083227
2019-03-26 08:35 kgv Note Added: 0083228
2019-03-26 08:35 kgv Assigned To galbramc => bugmaster
2019-03-26 11:13 apn Test case number => Not needed
2019-03-26 11:13 apn Status feedback => verified
2019-03-26 11:13 apn Resolution open => fixed