]> OCCT Git - occt.git/commitdiff
0032930: Modeling Algorithms - Crash in PerformIntersectionAtEnd when no face was...
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:48:22 +0000 (17:48 +0300)
The PerformIntersectionAtEnd code is currently not handling all the faces
correctly. If it retrieves Face[0] as F, it can happen that the previously
ran code didn't actually retrieve any faces in this array at all.

For example when:

* "if (nface==3)" is true
  - "if (!findonf1)" is true (doesn't assign any faces to this array)
  - "if (!findonf2)" is true (doesn't assign any faces to this array)
  - "if (state == ChFiDS_OnSame)" is not true (because it is
    ChFiDS_AllSame)
  - "if (findonf1 && !isOnSame1)" cannot be true (see above, but would
    handle faces)
  - "if (findonf2 && !isOnSame2)" cannot be true (see above, but would
    handle faces)
  - "if (isOnSame2)" is false (but would also handle faces)

Since no faces were assigned here, F would be a NULL face. As result, the
function will crash when trying to access the Surface behind the face via
`BRep_Tool::Surface(F);`.

While the best approach would be to identify the implementation bug in the
algorithm behind PerformIntersectionAtEnd, a check + exception is used
instead because the actual algorithm is not known.

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

index 93f20646acb2c44ed29b68964d71f48d0a7c714f..1996ca9d199b8c8b822df0107d1f48638377a969 100644 (file)
@@ -2115,6 +2115,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
       F=Face[nb-1];
       if (!prolface[nb-1]) faceprol[nb-1]=F;
     }
+
+    if (F.IsNull()) throw Standard_NullObject("IntersectionAtEnd : Trying to intersect with NULL face");
+
     Sfacemoins1=BRep_Tool::Surface(F);
     Handle(Geom_Curve) cint;
     Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
diff --git a/tests/bugs/modalg_8/bug32930 b/tests/bugs/modalg_8/bug32930
new file mode 100644 (file)
index 0000000..be24c74
--- /dev/null
@@ -0,0 +1,26 @@
+puts "TODO OCC32930 ALL: Tcl Exception"
+puts "TODO OCC32930 ALL: TEST INCOMPLETE"
+
+puts "============"
+puts "OCC32930: Modeling Algorithms - Crash in PerformIntersectionAtEnd when no face was found"
+puts "============"
+puts ""
+
+# Load & prepare data.
+restore [locate_data_file bug32930.brep] b
+explode b E
+
+# Make screenshot before filleting.
+smallview
+donly b b_10
+fit
+xwd $imagedir/${test_image}_1.png
+
+# Make fillet.
+blend result b 1 b_10
+
+# Make screenshot after filleting.
+donly result
+fit
+xwd $imagedir/${test_image}_2.png
+