]> OCCT Git - occt.git/commitdiff
0032929: Modeling Algorithms - Crash in PerformIntersectionAtEnd after deletion of... IR-2022-06-04
authorCharlemagne Lasse <charlemagnelasse@gmail.com>
Wed, 13 Apr 2022 09:54:30 +0000 (11:54 +0200)
committerafokin <afokin@opencascade.com>
Fri, 3 Jun 2022 14:51:01 +0000 (17:51 +0300)
When creating a fillet, num is calculated via ChFi3d_IndexOfSurfData. If it
returns just the number of entries in surfdata, it can happen that this
value becomes invalid when handling the case "two faces common to the edge
are found". When both components are on an arc, there will be num removed
from the surfdata.

num would then be larger than the number of entries surfdata. The derived
num1 is therefore also incorrect. The subsequent usage of this
value will either:

* Debug build: cause an out of bounds exception in ChangeValue
  (`SeqFil.ChangeValue(num)`)
* Release build: cause a segfault when retrieving it via index num1
  (`SeqFil(num1)`)

num + num1 must be recalculated after the deletion happens to correctly
calculate the fillet.

Signed-off-by: Charlemagne Lasse <charlemagnelasse@gmail.com>
src/ChFi3d/ChFi3d_Builder_C1.cxx
tests/bugs/modalg_8/bug32929 [new file with mode: 0644]

index 1996ca9d199b8c8b822df0107d1f48638377a969..da727d1a35efa006d647c9c995d6a9791ad64e2a 100644 (file)
@@ -1645,6 +1645,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
       }
       if (compoint1 && compoint2) {
        SeqFil.Remove(num);
+       num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
+       if (isfirst) {
+         num1=num+1;
+       }
+       else {
+         num1=num-1;
+       }
         reg1=Standard_False; reg2=Standard_False;
       }
     }
diff --git a/tests/bugs/modalg_8/bug32929 b/tests/bugs/modalg_8/bug32929
new file mode 100644 (file)
index 0000000..cb82a99
--- /dev/null
@@ -0,0 +1,44 @@
+puts "============"
+puts "OCC32929: Modeling Algorithms - Crash in PerformIntersectionAtEnd after deletion of surfdata (fillet)"
+puts "============"
+puts ""
+
+# Load & prepare data.
+restore [locate_data_file bug32929.brep] b
+explode b E
+
+# Make screenshot before filleting.
+smallview
+donly b b_8
+fit
+xwd $imagedir/${test_image}_1.png
+
+# Make fillet.
+blend result b 1 b_8
+
+# Make screenshot after filleting.
+donly result
+fit
+xwd $imagedir/${test_image}_2.png
+
+# Check mass.
+checkprops result -s 13435.4
+
+# Check validity of result.
+checkshape result
+
+# Check content.
+set nbshapes_expected "
+Number of shapes in shape
+ VERTEX    : 25
+ EDGE      : 40
+ WIRE      : 17
+ FACE      : 17
+ SHELL     : 1
+ SOLID     : 1
+ COMPSOLID : 0
+ COMPOUND  : 1
+ SHAPE     : 102
+"
+
+checknbshapes result -ref ${nbshapes_expected} -t -m "Result of ChFi3d_ChBuilder algorithm"