Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031601Community[OCCT] OCCT:Modeling Algorithmspublic2020-06-07 17:502020-06-07 17:50
Assigned Tomsv 
PlatformLinuxOSDebian 6.0OS Version64 bit
Product Version[OCCT] 7.3.0 
Target VersionFixed in Version 
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
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
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2020-06-07 17:50 abdullah New Issue
2020-06-07 17:50 abdullah Assigned To => msv

Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker