View Issue Details

IDProjectCategoryView StatusLast Update
0031601CommunityOCCT:Modeling Algorithmspublic2022-10-24 10:40
Reporterabdullah Assigned Tovmigunov 
Status assignedResolutionopen 
PlatformLinuxOSDebian 6.0 
Product Version7.3.0 
Target Version7.8.0 
Summary0031601: BRepOffset_Tool - Segmentation Fault
A patch as possible solution is provided.

This has been tested and reproduced against development branch 7.4.1, commit ae58f70718a089f84178d45a1bf9bee586d52d80

This bug is based on the FreeCAD bug:

The segmentation fault happens in function BRepOffset_Tool::TryProject.

In the following code (starting in line 1815):

   TopoDS_Edge CurE = TopoDS::Edge(it.Value());
    Handle(Geom_Curve) C = BRep_Tool::Curve(CurE,L,f,l);
    if (C.IsNull()) {
      C = BRep_Tool::Curve(CurE,L,f,l);
    C = new Geom_TrimmedCurve(C,f,l);

The curve produced by the call to BRep_Tool::Curve(CurE,L,f,l) is null.

Consequently the curve inserted into the constructor of Geom_TrimmedCurve is null. This causes the segfault.

I do not know whether BuildCurve3d is faulty (it should necessarily provide a non-null curve or not). I only know that in this specific case, it produces a null curve.

A possible solution to avoid the segmentation fault (see patch below), is to test whether the curve produced by BuildCurve3d is null.

An alternative to returning Standard_False (as in the patch) is to raise an exception. As no other function of this class raises an exception. None of the other functions of this class returns an exception, this my unqualified reason for returning Standard_False instead. You know the code better than me and may prefer an exception instead.

Steps To Reproduce
box b 50 50 10
explode b E
compound b_1 b_2 b_3 b_4 b_5 b_6 b_7 b_8 b_9 b_10 b_11 b_12 c
fillet s b 4 c
explode s F
offsetparameter 1.e-7 c a
offsetload s 1 s_11
offsetperform r
# OSD_Exception_ACCESS_VIOLATION: ACCESS VIOLATION at address 0x0000000000000000 during 'READ' operation

This bug is based on the FreeCAD bug:

It is not easy to provide a way to reproduce it without FreeCAD. I am running a setup using a locally build FreeCAD with a locally build development branch of OCCT:

I think that based on the analysis above, you will be interested in preventing the segfault.

Of course, if you want to provide other code and would like me to test a possible patch or else, just contact me. I am ready to help.

Additional information
and documentation updates
This is a patch that prevents the segmentation fault.

diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx
index af3ac106e1..b7c0d2310c 100644
--- a/src/BRepOffset/BRepOffset_Tool.cxx
+++ b/src/BRepOffset/BRepOffset_Tool.cxx
@@ -1820,0 +1821,3 @@ Standard_Boolean BRepOffset_Tool::TryProject
+ if (C.IsNull())
+ return Standard_False;
TagsNo tags attached.
Test case number



2022-02-14 11:19

developer   ~0106886

Dear abdullah, It would help a lot in reproduction and fixing this bug if you provided a piece of isolated code that causes this bug. It will be OK if it will be a complete program with main() function doing all stuff.

Issue History

Date Modified Username Field Change
2020-06-07 17:50 abdullah New Issue
2020-06-07 17:50 abdullah Assigned To => msv
2022-02-14 11:19 msv Note Added: 0106886
2022-06-24 15:48 azv Assigned To msv => vmigunov
2022-06-24 15:48 azv Target Version => 7.7.0
2022-06-24 15:48 azv Steps to Reproduce Updated
2022-06-24 15:48 azv Status new => assigned
2022-07-05 08:57 vmigunov Status assigned => resolved
2022-07-05 08:58 vmigunov Assigned To vmigunov => azv
2022-07-05 09:02 vmigunov Assigned To azv => vmigunov
2022-07-05 09:02 vmigunov Status resolved => assigned
2022-10-24 10:40 szy Target Version 7.7.0 => 7.8.0