Archived issue #0032744
Modeling Algorithms - Endless loop in GCPnts_UniformDeflection
Description
To reproduce memory leak and endless loop inside GCPnts_UniformDeflection constructor it’s enough to read Attachment 1 (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.
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 reproduce
TopoDS_Compound comp;
BRep_Builder builder;
BRepTools::Read(comp, "/path/to/Attachment 1 (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
}
}
BRep_Builder builder;
BRepTools::Read(comp, "/path/to/Attachment 1 (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
From TSYS-16-006
Public activity
16 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been created by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Mon Dec 20 19:27:09 2021 +0300
0032744: Modeling Algorithms - Memory leak in GCPnts_UniformDeflection
fixed CPnts_UniformDeflection::More()
[revision removed]
Detailed log of new commits:
Author: Author
Date: Mon Dec 20 19:27:09 2021 +0300
0032744: Modeling Algorithms - Memory leak in GCPnts_UniformDeflection
fixed CPnts_UniformDeflection::More()
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
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-Author/view/COMPARE/
Unstable cases are different for win & Linux platforms and seems like not related to this issue
Tests results are here: http://jenkins-test-occt.nnov.opencascade.com/view/CR32744-master-Author/view/COMPARE/
Unstable cases are different for win & Linux platforms and seems like not related to this issue
myFirstParam == myFirstParam + myDu;
It is better using myDu < Epsilon (myFirstParam)
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.
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
remarks fixed.
tests results: http://jenkins-test-occt.nnov.opencascade.com/view/CR32744-master-Author/view/COMPARE/
tests results: http://jenkins-test-occt.nnov.opencascade.com/view/CR32744-master-Author/view/COMPARE/
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
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.
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
fixed
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
For integration:
occt - CR32744
products - none
occt - CR32744
products - none
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
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
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
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
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]