Archived issue #0027125
Crashes in BRepFilletAPI_MakeFillet
Description
We have found some crashes in the fillet algorithm. The problematic area is the PerformOneCorner method, that has several problems. Currently I have reproduction for only one issue, and crash logs for many other. The reproduction for the other case is attached.
If I will find a reproduction for this case I will attach it, but I suppose they are somehow related.
Stack trace 1:
1
Crashed: AsyncProcessor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
raw
0 TKG2d
Geom2d_Curve::Value(double) const + 16
1
TKFillet
ChFi3d_Builder::PerformMoreThreeCorner(int, int) + 53440
2
TKFillet
ChFi3d_Builder::PerformIntersectionAtEnd(int) + 8000
3
TKFillet
ChFi3d_Builder::PerformOneCorner(int, unsigned int) + 4188
4
TKFillet
ChFi3d_Builder::PerformFilletOnVertex(int) + 1024
5
TKFillet
ChFi3d_Builder::Compute() + 1680
6 TKFillet
BRepFilletAPI_MakeFillet::Build() + 36
If I will find a reproduction for this case I will attach it, but I suppose they are somehow related.
Stack trace 1:
1
Crashed: AsyncProcessor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
raw
0 TKG2d
Geom2d_Curve::Value(double) const + 16
1
TKFillet
ChFi3d_Builder::PerformMoreThreeCorner(int, int) + 53440
2
TKFillet
ChFi3d_Builder::PerformIntersectionAtEnd(int) + 8000
3
TKFillet
ChFi3d_Builder::PerformOneCorner(int, unsigned int) + 4188
4
TKFillet
ChFi3d_Builder::PerformFilletOnVertex(int) + 1024
5
TKFillet
ChFi3d_Builder::Compute() + 1680
6 TKFillet
BRepFilletAPI_MakeFillet::Build() + 36
Steps to reproduce
restore Attachment 3 (BREP) a
subshape a e 39
if {[catch {puts [blend r a 7.5 a_39]}]} {
puts "Error: exception in blend"
}
subshape a e 39
if {[catch {puts [blend r a 7.5 a_39]}]} {
puts "Error: exception in blend"
}
Public activity
9 archived notes
Participants are labeled by their role within this record.
Hello Istvan, do you observe this issue on iOS / OS X only (with CLang), or on some another platform?
Clang + iOS/Mac
Have you tried the repro code I attached on Windows?
I have reproduced the problem in Attachment 2 (CPP). I have got access violation signal. However the stack is slightly another:
> TKG2d.dll!Geom2d_Curve::Value(const double U) Line 88 C++
TKFillet.dll!ChFi3d_Builder::PerformOneCorner(const int Index, const unsigned int thePrepareOnSame) Line 1249 C++
TKFillet.dll!ChFi3d_Builder::PerformFilletOnVertex(const int Index) Line 747 C++
TKFillet.dll!ChFi3d_Builder::Compute() Line 303 C++
TKFillet.dll!BRepFilletAPI_MakeFillet::Build() Line 534 C++
When running this algorithm under Draw the exception is caught by try/catch block in the method ChFi3d_Builder::Compute(), and therefore it does not lead to application crash. It is because of call to OSD::SetSignal() method in main thread function of Draw application.
It is interesting if SetSignal can do its work under iOS. This could be a good work around crashes on this platform.
Meanwhile, this is a bug and the cause of calling Value() of null pcurve should be investigated.
> TKG2d.dll!Geom2d_Curve::Value(const double U) Line 88 C++
TKFillet.dll!ChFi3d_Builder::PerformOneCorner(const int Index, const unsigned int thePrepareOnSame) Line 1249 C++
TKFillet.dll!ChFi3d_Builder::PerformFilletOnVertex(const int Index) Line 747 C++
TKFillet.dll!ChFi3d_Builder::Compute() Line 303 C++
TKFillet.dll!BRepFilletAPI_MakeFillet::Build() Line 534 C++
When running this algorithm under Draw the exception is caught by try/catch block in the method ChFi3d_Builder::Compute(), and therefore it does not lead to application crash. It is because of call to OSD::SetSignal() method in main thread function of Draw application.
It is interesting if SetSignal can do its work under iOS. This could be a good work around crashes on this platform.
Meanwhile, this is a bug and the cause of calling Value() of null pcurve should be investigated.
I have put the draw script in steps to reproduce.
Another similar issue:
8
Crashed: AsyncProcessor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010
raw
0
TKFillet
ChFi3d_FilBuilder_C2.cxx line 520
ChFi3d_FilBuilder::PerformTwoCorner(int)
1
TKFillet
ChFi3d_Builder.cxx line 758
ChFi3d_Builder::PerformFilletOnVertex(int)
2
TKFillet
ChFi3d_Builder.cxx line 298
ChFi3d_Builder::Compute()
3
TKFillet
BRepFilletAPI_MakeFillet.cxx line 533
BRepFilletAPI_MakeFillet::Build()
8
Crashed: AsyncProcessor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010
raw
0
TKFillet
ChFi3d_FilBuilder_C2.cxx line 520
ChFi3d_FilBuilder::PerformTwoCorner(int)
1
TKFillet
ChFi3d_Builder.cxx line 758
ChFi3d_Builder::PerformFilletOnVertex(int)
2
TKFillet
ChFi3d_Builder.cxx line 298
ChFi3d_Builder::Compute()
3
TKFillet
BRepFilletAPI_MakeFillet.cxx line 533
BRepFilletAPI_MakeFillet::Build()
SImilar problems happen with chamfers:
10
Crashed: AsyncProcessor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000060
raw
0
TKBRep
NCollection_TListIterator.hxx line 44
BRep_Tool::CurveOnSurface(TopoDS_Edge const&, opencascade::handle<Geom_Surface> const&, TopLoc_Location const&, double&, double&)
1
TKBRep
Standard_Handle.hxx line 78
BRep_Tool::CurveOnSurface(TopoDS_Edge const&, TopoDS_Face const&, double&, double&)
2
TKBRep
BRepAdaptor_Curve2d.cxx line 56
BRepAdaptor_Curve2d::Initialize(TopoDS_Edge const&, TopoDS_Face const&)
3
TKFillet
Standard_Handle.hxx line 114
ChFi3d_Builder::StartSol(opencascade::handle<ChFiDS_Spine> const&, opencascade::handle<BRepAdaptor_HSurface>&, gp_Pnt2d&, opencascade::handle<BRepAdaptor_HCurve2d>&, double&, opencascade::handle<ChFiDS_SurfData> const&, unsigned int, int, opencascade::handle<BRepAdaptor_HSurface>&, opencascade::handle<BRepAdaptor_HCurve2d>&, unsigned int&, unsigned int&, unsigned int&, unsigned int&, opencascade::handle<BRepAdaptor_HSurface>&, gp_Pnt2d&, unsigned int, TopoDS_Vertex const&) const
4
TKFillet
ChFi3d_Builder_2.cxx line 1964
ChFi3d_Builder::PerformSetOfSurfOnElSpine(opencascade::handle<ChFiDS_HElSpine> const&, opencascade::handle<ChFiDS_Stripe>&, opencascade::handle<BRepTopAdaptor_TopolTool>&, opencascade::handle<BRepTopAdaptor_TopolTool>&, unsigned int)
5
TKFillet
NCollection_BaseList.hxx line 53
ChFi3d_Builder::PerformSetOfKGen(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
6
TKFillet
ChFi3d_Builder_2.cxx line 2980
ChFi3d_Builder::PerformSetOfSurf(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
7
TKFillet
ChFi3d_Builder.cxx line 268
ChFi3d_Builder::Compute()
8
TKFillet
BRepFilletAPI_MakeChamfer.cxx line 389
BRepFilletAPI_MakeChamfer::Build()
10
Crashed: AsyncProcessor
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000060
raw
0
TKBRep
NCollection_TListIterator.hxx line 44
BRep_Tool::CurveOnSurface(TopoDS_Edge const&, opencascade::handle<Geom_Surface> const&, TopLoc_Location const&, double&, double&)
1
TKBRep
Standard_Handle.hxx line 78
BRep_Tool::CurveOnSurface(TopoDS_Edge const&, TopoDS_Face const&, double&, double&)
2
TKBRep
BRepAdaptor_Curve2d.cxx line 56
BRepAdaptor_Curve2d::Initialize(TopoDS_Edge const&, TopoDS_Face const&)
3
TKFillet
Standard_Handle.hxx line 114
ChFi3d_Builder::StartSol(opencascade::handle<ChFiDS_Spine> const&, opencascade::handle<BRepAdaptor_HSurface>&, gp_Pnt2d&, opencascade::handle<BRepAdaptor_HCurve2d>&, double&, opencascade::handle<ChFiDS_SurfData> const&, unsigned int, int, opencascade::handle<BRepAdaptor_HSurface>&, opencascade::handle<BRepAdaptor_HCurve2d>&, unsigned int&, unsigned int&, unsigned int&, unsigned int&, opencascade::handle<BRepAdaptor_HSurface>&, gp_Pnt2d&, unsigned int, TopoDS_Vertex const&) const
4
TKFillet
ChFi3d_Builder_2.cxx line 1964
ChFi3d_Builder::PerformSetOfSurfOnElSpine(opencascade::handle<ChFiDS_HElSpine> const&, opencascade::handle<ChFiDS_Stripe>&, opencascade::handle<BRepTopAdaptor_TopolTool>&, opencascade::handle<BRepTopAdaptor_TopolTool>&, unsigned int)
5
TKFillet
NCollection_BaseList.hxx line 53
ChFi3d_Builder::PerformSetOfKGen(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
6
TKFillet
ChFi3d_Builder_2.cxx line 2980
ChFi3d_Builder::PerformSetOfSurf(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
7
TKFillet
ChFi3d_Builder.cxx line 268
ChFi3d_Builder::Compute()
8
TKFillet
BRepFilletAPI_MakeChamfer.cxx line 389
BRepFilletAPI_MakeChamfer::Build()
Not sure if this is related, but can be (bad_alloc, and the user had lots of memory left)
9 libc++abi.dylib
std::__terminate(void (*)()) + 16
10
libc++abi.dylib
__cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 134
11 libc++abi.dylib
operator new(unsigned long) + 96
12
TKG3d
NCollection_Array1.hxx line 165
Geom_BSplineCurve::Segment(double, double)
13
TKFillet
ChFi3d_Builder_0.cxx line 4258
ChFi3d_PerformElSpine(opencascade::handle<ChFiDS_HElSpine>&, opencascade::handle<ChFiDS_Spine>&, GeomAbs_Shape, double)
14
TKFillet
NCollection_BaseList.hxx line 53
ChFi3d_Builder::PerformSetOfKPart(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
15
TKFillet
ChFi3d_Builder_2.cxx line 2973
ChFi3d_Builder::PerformSetOfSurf(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
16
TKFillet
ChFi3d_Builder.cxx line 268
ChFi3d_Builder::Compute()
17
TKFillet
BRepFilletAPI_MakeChamfer.cxx line 389
BRepFilletAPI_MakeChamfer::Build()
9 libc++abi.dylib
std::__terminate(void (*)()) + 16
10
libc++abi.dylib
__cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 134
11 libc++abi.dylib
operator new(unsigned long) + 96
12
TKG3d
NCollection_Array1.hxx line 165
Geom_BSplineCurve::Segment(double, double)
13
TKFillet
ChFi3d_Builder_0.cxx line 4258
ChFi3d_PerformElSpine(opencascade::handle<ChFiDS_HElSpine>&, opencascade::handle<ChFiDS_Spine>&, GeomAbs_Shape, double)
14
TKFillet
NCollection_BaseList.hxx line 53
ChFi3d_Builder::PerformSetOfKPart(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
15
TKFillet
ChFi3d_Builder_2.cxx line 2973
ChFi3d_Builder::PerformSetOfSurf(opencascade::handle<ChFiDS_Stripe>&, unsigned int)
16
TKFillet
ChFi3d_Builder.cxx line 268
ChFi3d_Builder::Compute()
17
TKFillet
BRepFilletAPI_MakeChamfer.cxx line 389
BRepFilletAPI_MakeChamfer::Build()
Just encountered the same reported issue on OCCT 7.3.0 and 7.4.0.
In DRAW:
restore Attachment 1 (BREP)
explode fds E
if {[catch {puts [blend r fds 3.2 fds_6 3.2 fds_10]}]} {puts "Error: exception in blend"}
The try/catch block in the method ChFi3d_Builder::Compute() does not catch one of the occuring exceptions (there is a for-loop, where multiple exceptions are raised in this example). With fillet-radius 2.0 (instead of 3.2) the occuring exceptions are catched by the try/catch block.
However, the exceptions seem to be handled in DRAW always.
In DRAW:
restore Attachment 1 (BREP)
explode fds E
if {[catch {puts [blend r fds 3.2 fds_6 3.2 fds_10]}]} {puts "Error: exception in blend"}
The try/catch block in the method ChFi3d_Builder::Compute() does not catch one of the occuring exceptions (there is a for-loop, where multiple exceptions are raised in this example). With fillet-radius 2.0 (instead of 3.2) the occuring exceptions are catched by the try/catch block.
However, the exceptions seem to be handled in DRAW always.