DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0024909

Modeling Algorithms - SIGSEGV in buildsweep

CommunityOCCT:Modeling Algorithmsassigned18 public notes

Search issues

Description

Some sweeps cause segmentation faults. The original problem is described http://www.freecadweb.org/tracker/view.php?id=1419 .

version tested 73192b374

Steps to reproduce

bugs modalg_7 bug24909_1, bug24909_2, bug24909_3, bug24909_4

Public activity

18 archived notes

Participants are labeled by their role within this record.

01Author
if either of the sections is omitted the sweep returns a result.
02Author
the following script reproduces the problem without relying on external BREPs

pload ALL
circle c1 0 0 0 40
mkedge e1 c1
wire w1 e1
tcopy w1 Sketch002
tcopy w1 Sketch001
renamevar w1 Sketch
trotate Sketch 0 0 0 0. 1. 0. 90
ttranslate Sketch 0. 0. 75.
trotate Sketch001 0 0 0 0. 1. 0. 90
ttranslate Sketch001 0. 0. -75.
ttranslate Sketch002 50. 0. 0.
mksweep Sketch002
setsweep -CF
addsweep Sketch001
addsweep Sketch
buildsweep Sweep

#An exception was caught 0x7f61f1538031 : OSD_SIGSEGV: SIGSEGV 'segmentation violation' detected. Address 10
#** Exception ** 0x7f61f1538031 : OSD_SIGSEGV: SIGSEGV 'segmentation violation' detected. Address 10
03Author
#additional example for test case creation

#generated by FreeCAD 0.15.4119 +12 (Git)
pload MODELING
#saved shape of Part::Part2DObjectPython::Draft._BezCurve Object
restore minihyd-draw-BezCurve.brep BezCurve
ttranslate BezCurve 0 -8 0
explode BezCurve E
wire Sweep001-0-spine BezCurve_1
mksweep Sweep001-0-spine
setsweep -CF
circle Circle-curve 0 0 0 18
mkedge Circle-edge Circle-curve 0 0
wire Circle Circle-edge
trotate Circle 0 0 0 0.577350269189625731 0.577350269189625731 0.577350269189625731 120
ttranslate Circle 0 -71 203.5
addsweep Circle
circle Circle001-curve 0 0 0 16
mkedge Circle001-edge Circle001-curve 0 0
wire Circle001 Circle001-edge
trotate Circle001 0 0 0 0.577350269189625731 0.577350269189625731 0.577350269189625731 120
ttranslate Circle001 0 -71 203.5
addsweep Circle001
buildsweep Sweep001 -C -S
donly Sweep001


#SIGSEGV, Segmentation fault.
#0x00007fff8aab9559 in GeomFill_Array1OfSectionLaw::Value (this=0x10, Index=1)
# at occt-eb46b12/inc/TCollection_Array1.lxx:119
#119 Standard_OutOfRange_Raise_if((Index < myLowerBound || Index > myUpperBound),NULL);
04Author
The test case Attachment 7 (DRAW) seems to be affected by #0025453 it does not longer create a sigsegv but a faulty shape
> checkshape Sweep
On Shape faulty_1 :
BRepCheck_UnorientableShape
Shape faulty_2 on shape faulty_1 :
BRepCheck_BadOrientationOfSubshape
On Shape faulty_3 :
BRepCheck_UnorientableShape
Shape faulty_4 on shape faulty_3 :
BRepCheck_BadOrientationOfSubshape

Faulty shapes in variables faulty_1 to faulty_4


But the other two examples (minihyd and from c29262) still create a SIGSEGV

05Author
I got a new user report that generates a similar stacktrace. (DRAWEXE example included in Attachment 2 (ZIP))

06Author
I got a new user report that generates a similar stacktrace. (DRAWEXE example included in Attachment 3 (ZIP))
it involves an ellipse with negative parameter range:
"mkedge Ellipse-edge Ellipse-curve 3.141592653589793 0"

Program received signal SIGSEGV, Segmentation fault.
0x00007f97c7135eb1 in GeomFill_Array1OfSectionLaw::Value (this=0x10, Index=1)
    at occt/inc/TCollection_Array1.lxx:119
119	  Standard_OutOfRange_Raise_if((Index < myLowerBound || Index > myUpperBound),NULL);
07Commenter 7
Problem described in issue is reproduced on current state of OCCT.
08Commenter 8
Also we have an exception on following script (trying to sweep line along circle if line starts from circle's center):

pload ALL
circle c1 0 0 0 40
mkedge e1 c1
wire w1 e1
line l1 0 0 0 0 0 20
mkedge e2 l1 0 10
wire w2 e2
mksweep w1
addsweep w2
buildsweep sw1
09Commenter 1
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: asuraven
Date: Mon Jan 17 11:42:16 2022 +0300

    0024909: Modeling Algorithms - SIGSEGV in buildsweep
    
    Change NCollection_DataMap NCollection_IndexedDataMap to avoid undefined behavior in BRepFill_CompatibleWires::SameNumberByPolarMethod()
    
    Correction in BRepFill_PipeShell::Prepare()
10Commenter 1
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
11Commenter 1
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
12Commenter 1
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
13Commenter 1
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
14Commenter 1
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: akondrat
Date: Wed Aug 10 13:45:58 2022 +0300

    0024909: Modeling Algorithms - SIGSEGV in buildsweep
    
    Update algorithm.
15Commenter 15
-	    for (ii=1; ii<=Ext.NbExt(); ii++) {
+	    for (ii=1; ii<Ext.NbExt(); ii++) {

Why do you ignore the last solution?
16Commenter 1
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
17Commenter 1
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
18Commenter 18
Wrong indentation (when using tab size 8):
         (U2 >= Ut21 - RealEpsilon())  &&
         (U2 <= Ut22 + RealEpsilon())) {
       Val = AlgExt.SquareDistance(i);
+    if (mypoints.IsEmpty())
+      mySqDist.Clear();
       mySqDist.Append(Val);
           if (!theIsInverse)

The same is in the file BRepFill_CompatibleWires.cxx, line 1159.

src/TopTools/TopTools_IndexedDataMapOfShapeListOfShape.hxx
Changes in this file bring inconsistency with other TopTools_Indexed*.hxx files. I propose to revert it and use TopTools_IndexedDataMapOfShapeListOfShape::Iterator where it is needed.

Why the new version passes map parameter by value?
 static Standard_Boolean SearchRoot (const TopoDS_Vertex& V,
-				    const TopTools_DataMapOfShapeListOfShape& Map,
-				    TopoDS_Vertex& VRoot)
+                                    const TopTools_IndexedDataMapOfShapeListOfShape Map,
+                                    TopoDS_Vertex& VRoot)


This code (line 1000) looks overcomplicated, taking into account that Init is an empty list:
      TopTools_ListOfShape* aShapeList = RMap.ChangeSeek(Vi);
      if (!aShapeList)
        aShapeList = &RMap(RMap.Add(Vi, Init));
      aShapeList->Append(Init);


Here (line 1041), aShapeList may take duplicated shape Vi.
    TopTools_ListOfShape* aShapeList = MapVLV.ChangeSeek(Vi);
    if (!aShapeList)
      aShapeList = &MapVLV(MapVLV.Add(Vi, Init));
    aShapeList->Append(Init);

Related records