From 24e4b3c83b237dad583f87c983eb06433d56c203 Mon Sep 17 00:00:00 2001 From: Charlemagne Lasse Date: Wed, 13 Apr 2022 11:54:30 +0200 Subject: [PATCH] 0032929: Modeling Algorithms - Crash in PerformIntersectionAtEnd after deletion of surfdata 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 --- src/ChFi3d/ChFi3d_Builder_C1.cxx | 7 +++++ tests/bugs/modalg_8/bug32929 | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/bugs/modalg_8/bug32929 diff --git a/src/ChFi3d/ChFi3d_Builder_C1.cxx b/src/ChFi3d/ChFi3d_Builder_C1.cxx index 1996ca9d19..da727d1a35 100644 --- a/src/ChFi3d/ChFi3d_Builder_C1.cxx +++ b/src/ChFi3d/ChFi3d_Builder_C1.cxx @@ -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 index 0000000000..cb82a99889 --- /dev/null +++ b/tests/bugs/modalg_8/bug32929 @@ -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"