View Issue Details

IDProjectCategoryView StatusLast Update
0032744Open CASCADEOCCT:Modeling Algorithmspublic2022-01-02 13:36
Reporterasuraven Assigned Toasuraven  
PrioritynormalSeverityminor 
Status verifiedResolutionfixed 
Target Version7.7.0 
Summary0032744: Modeling Algorithms - Endless loop in GCPnts_UniformDeflection
DescriptionTo reproduce memory leak and endless loop inside GCPnts_UniformDeflection constructor it’s enough to read bad_edge.brep by BRepTools::Read() function.
To find out why such “valid“ edges are produced by JTCAFControl_Reader converter, you can read JT file and transfer it to TDocStd_Documen document and then iterate through gotten shapes checking each edge by GCPnts_UniformDeflection algorithm.
Steps To ReproduceTopoDS_Compound comp;
BRep_Builder builder;
BRepTools::Read(comp, "/path/to/bad_edge.brep", builder);
BRepCheck_Analyzer analyzer(comp);
if (analyzer.IsValid()) {
  TopTools_IndexedMapOfShape edges;
  TopExp::MapShapes(comp, TopAbs_EDGE, edges);
  for (auto edgeNum = 1; edgeNum <= edges.Extent(); ++edgeNum)
  {
    auto edge = TopoDS::Edge(edges(edgeNum));
    Standard_Real firstParam = 0., lastParam = 0.;
    auto pCurve = BRep_Tool::Curve(edge, firstParam, lastParam);
    GeomAdaptor_Curve curveAdaptor(pCurve, firstParam, lastParam);
    GCPnts_UniformDeflection uniformAbs(curveAdaptor, 0.001, firstParam, lastParam); // <= endless loop and memory leak inside
  }
}
Additional information
and documentation updates
From TSYS-16-006
TagsNo tags attached.
Test case numberbugs/modalg_7/bug32744

Attached Files

  • bad_edge.brep (84,011 bytes)

Activities

asuraven

2021-12-20 11:22

developer  

bad_edge.brep (84,011 bytes)

git

2021-12-20 19:27

administrator   ~0106116

Branch CR32744 has been created by asuraven.

SHA-1: c8316186a1ff7d7522d8290e2c130d9fe539ff3b


Detailed log of new commits:

Author: asuraven
Date: Mon Dec 20 19:27:09 2021 +0300

    0032744: Modeling Algorithms - Memory leak in GCPnts_UniformDeflection
    
    fixed CPnts_UniformDeflection::More()

git

2021-12-21 13:33

administrator   ~0106126

Branch CR32744 has been updated forcibly by asuraven.

SHA-1: 15442d43d6694498158e418cce9f5256684d29c3

asuraven

2021-12-21 16:20

developer   ~0106130

In this extremal case the parameter increment in CPnts_UniformDeflection::Perform() is less than the parameter's value precision. For this reason, the parameter value has not been changed, the loop becomes endless.
Tests results are here: http://jenkins-test-occt.nnov.opencascade.com/view/CR32744-master-ASURAVEN/view/COMPARE/
Unstable cases are different for win & Linux platforms and seems like not related to this issue

msv

2021-12-21 18:38

developer   ~0106134

               myFirstParam == myFirstParam + myDu;

It is better using myDu < Epsilon (myFirstParam)

msv

2021-12-21 18:43

developer   ~0106135

About test case, it is better to read the shape using standard restore command and pass to the test command the shape instead of file name.

git

2021-12-22 12:52

administrator   ~0106138

Branch CR32744 has been updated forcibly by asuraven.

SHA-1: 2c3909764ef20f326bc6381be49e181ed41f571f

git

2021-12-22 14:43

administrator   ~0106148

Branch CR32744 has been updated forcibly by asuraven.

SHA-1: 29136f4b06af019f4b2d59b7fe33a27e0b98ccb1

asuraven

2021-12-22 20:18

developer   ~0106154

remarks fixed.
tests results: http://jenkins-test-occt.nnov.opencascade.com/view/CR32744-master-ASURAVEN/view/COMPARE/

git

2021-12-23 10:31

administrator   ~0106162

Branch CR32744 has been updated forcibly by asuraven.

SHA-1: ae66270d19dfd58b7218877127ca5546802d34fd

msv

2021-12-27 15:17

developer   ~0106216

    myFirstParam += myDu;
    myFinish = myLastParam - myFirstParam < myTolCur ||
               Abs(myDu) < myTolCur ||
               // to avoid less than double precision endless increment
               myDu < Epsilon (myFirstParam);

Please compute the value of Epsilon (myFirstParam) before entering the loop. It must be invariant.

  else if (aShape.ShapeType() != TopAbs_EDGE)
  {
    theDi << " Shape type must be EDGE\n";
    return 1;
  }

  const TopoDS_Edge& anEdge = *(TopoDS_Edge*) &aShape;

Use the method TopoDS:Edge() for safe downcasting of a shape to edge. After that just check the cast result for null shape.

git

2021-12-27 16:10

administrator   ~0106217

Branch CR32744 has been updated forcibly by asuraven.

SHA-1: 273e94c8a30a9a4dd969adf55a11e1c5ab56e4a7

asuraven

2021-12-27 16:11

developer   ~0106218

fixed

git

2021-12-27 17:17

administrator   ~0106219

Branch CR32744 has been updated forcibly by asuraven.

SHA-1: c6c7b0b83c620e8473a1b22d65e8937fbc7d9dee

msv

2021-12-27 17:20

developer   ~0106220

For integration:
occt - CR32744
products - none

smoskvin

2021-12-31 12:49

administrator   ~0106252

Combination -
OCCT branch : IR-2021-12-30
master SHA - 16a263dc17600ac13a5110bd7028ba558d1a0700
49e51745631c52b6c452c65adae4d6dfa21a1b1e
Products branch : IR-2021-12-30 SHA - fe496634abbd6a631b6f674703746ef8605cfe87
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: 18220.12000000046 / 18175.980000000385 [+0.24%]
Products
Total CPU difference: 11659.240000000125 / 11591.590000000113 [+0.58%]
Windows-64-VC14:
OCCT
Total CPU difference: 19997.15625 / 19974.59375 [+0.11%]
Products
Total CPU difference: 13120.265625 / 13088.65625 [+0.24%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2022-01-02 13:36

administrator   ~0106258

Branch CR32744 has been deleted by mnt.

SHA-1: c6c7b0b83c620e8473a1b22d65e8937fbc7d9dee

Related Changesets

occt: master 2ac4e1be

2021-12-20 19:27:09

asuraven


Committer: smoskvin Details Diff
0032744: Modeling Algorithms - Endless loop in GCPnts_UniformDeflection

fixed finish criteria in CPnts_UniformDeflection::Perform()
Affected Issues
0032744
mod - src/CPnts/CPnts_UniformDeflection.cxx Diff File
mod - src/QABugs/QABugs_20.cxx Diff File
add - tests/bugs/modalg_7/bug32744 Diff File

Issue History

Date Modified Username Field Change
2021-12-20 11:22 asuraven New Issue
2021-12-20 11:22 asuraven Assigned To => asuraven
2021-12-20 11:22 asuraven File Added: bad_edge.brep
2021-12-20 19:27 git Note Added: 0106116
2021-12-20 19:35 asuraven Time allocated 20.12.2021: 8 h. => set
2021-12-21 12:00 asuraven Summary Modeling Algorithms - Memory leak in GCPnts_UniformDeflection => Modeling Algorithms - Endless loop in GCPnts_UniformDeflection
2021-12-21 12:00 asuraven Description Updated
2021-12-21 12:00 asuraven Steps to Reproduce Updated
2021-12-21 13:33 git Note Added: 0106126
2021-12-21 14:30 asuraven Time allocated 21.12.2021: 4 h. => set
2021-12-21 16:20 asuraven Assigned To asuraven => msv
2021-12-21 16:20 asuraven Status new => resolved
2021-12-21 16:20 asuraven Note Added: 0106130
2021-12-21 18:38 msv Note Added: 0106134
2021-12-21 18:38 msv Assigned To msv => asuraven
2021-12-21 18:38 msv Status resolved => assigned
2021-12-21 18:43 msv Note Added: 0106135
2021-12-22 12:52 git Note Added: 0106138
2021-12-22 12:53 asuraven Time allocated 22.12.2021: 2 h. => set
2021-12-22 14:43 git Note Added: 0106148
2021-12-22 19:04 asuraven Time allocated 22.12.2021: 2 h. => set
2021-12-22 20:18 asuraven Assigned To asuraven => msv
2021-12-22 20:18 asuraven Status assigned => resolved
2021-12-22 20:18 asuraven Note Added: 0106154
2021-12-23 10:31 git Note Added: 0106162
2021-12-27 15:17 msv Assigned To msv => asuraven
2021-12-27 15:17 msv Status resolved => assigned
2021-12-27 15:17 msv Note Added: 0106216
2021-12-27 16:10 git Note Added: 0106217
2021-12-27 16:11 asuraven Assigned To asuraven => msv
2021-12-27 16:11 asuraven Status assigned => resolved
2021-12-27 16:11 asuraven Note Added: 0106218
2021-12-27 16:11 asuraven Time allocated 27.12.2021: 1 h. => set
2021-12-27 17:17 git Note Added: 0106219
2021-12-27 17:20 msv Assigned To msv => bugmaster
2021-12-27 17:20 msv Status resolved => reviewed
2021-12-27 17:20 msv Note Added: 0106220
2021-12-31 12:49 smoskvin Status reviewed => tested
2021-12-31 12:49 smoskvin Note Added: 0106252
2021-12-31 12:50 smoskvin Test case number => bugs/modalg_7/bug32744
2022-01-02 13:24 smoskvin Changeset attached => occt master 2ac4e1be
2022-01-02 13:24 asuraven Assigned To bugmaster => asuraven
2022-01-02 13:24 asuraven Status tested => verified
2022-01-02 13:24 asuraven Resolution open => fixed
2022-01-02 13:36 git Note Added: 0106258