[bug 4543] [crash] on applying fillet or chamfer

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [crash] on applying fillet or chamfer

Post by chennes »

uwestoehr wrote: Mon Jan 25, 2021 10:00 pm Yes, this was also my thought. OCC can fail so we must check if OCC could create the fillet and only then move on, otherwise abort/undo the operation.
It's not that simple: OCC thinks it can do the fillet. It's trying to do the fillet. And it's segfaulting because a chunk of memory that it assumes its earlier self initialized, it actually didn't. We can't "catch" something, etc., the OS is killing us because we're accessing memory that's not ours.

Now, knowing what the failure mechanism is, we could write some kind of stupid-looking test like:

Code: Select all

auto faces = getFacesForEdge(myEdgeToFillet);
OCC::Edge newEdge;
OCC::cherche_edge1(faces[0],faces[1], newEdge);
if (newEdge != myEdgeToFillet) {
	throw ("Something bad has happened");
}
(No, that's not real code, but it is cherche_edge1 failing to populate newEdge that is as far back as I've traced the error so far.)

(If anyone else is looking at this, I'm at line 1969 of opencascade-7.5.0\src\ChFi3d\ChFi3d_Builder_C1.cxx -- that call to cherche_edge1 is not actually finding a shared edge between the two faces, but OCC never checks that)
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by uwestoehr »

I am sorry for the mess I created here with the 2 threads. However, this one is now bound to the reported bug and should stay.
Werner commented on the topic today in the other one: https://forum.freecadweb.org/viewtopic. ... 10#p471034 and following
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by chennes »

OK. I see in that other discussion that there is a possibility of our patching OCC on our end and applying it somehow during the release process? If we can do that, I could draft a small patch that catches the failure I noted above and bails out of the operation: we won't achieve a successful fillet, but we won't crash out (probably... the failure to find that shared edge must itself be a symptom of some other problem).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by uwestoehr »

chennes wrote: Tue Jan 26, 2021 4:41 pm OK. I see in that other discussion that there is a possibility of our patching OCC on our end and applying it somehow during the release process? If we can do that, I could draft a small patch that catches the failure I noted above and bails out of the operation: we won't achieve a successful fillet, but we won't crash out (probably... the failure to find that shared edge must itself be a symptom of some other problem).
That would be amazing! Everything help if we don't crash anymore since one hand hand people think FC is an unstable program not worth to be used for real-life projects and on the other hand as it crashes, the user don't get any feedback why or what he made wrong.
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by chennes »

uwestoehr wrote: Tue Jan 26, 2021 5:19 pm the user don't get any feedback why or what he made wrong.
OK, I made a patch that makes the fillet fail more gracefully. It does not actually fix whatever the underlying problem is, I have not tracked that down yet, but it throws an exception if that edge finding algorithm fails to produce an edge, which ought never happen (but apparently does!). And since I don't know the problem, it just gives a generic "Could not make fillet" error message in FC. But in my testing, it does not crash out.

I've attached two files: a patch file from diff that you can use to patch your own copy of OpenCascade 7.5.0 if you are self-compiling, as well as a drop-in DLL replacement for TkFillet.dll, if you want to just try mine. I don't know how to go about submitting this "officially" though. Who does it go to?
Attachments
OCC-7.5.0-FilletFix-ChFi3d_Builder_C1.cxx.patch.7z
7zipped patch file for ChFi3d_Builder_C1.cxx
(921 Bytes) Downloaded 53 times
TKFillet.7z
TkFillet.dll OCC v7.5.0 with patch applied
(557.34 KiB) Downloaded 43 times
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by tanderson69 »

chennes wrote: Wed Jan 27, 2021 3:35 pmI don't know how to go about submitting this "officially" though. Who does it go to?
Official
My Unofficial
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by chennes »

I have submitted both a ticket and a change request upstream:
https://tracker.dev.opencascade.org/view.php?id=32181
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by realthunder »

chennes wrote: Sat Feb 27, 2021 10:51 pm I have submitted both a ticket and a change request upstream:
https://tracker.dev.opencascade.org/view.php?id=32181
I think there is a problem in your patch. A user reported the problem here, and I digged up a bit. I can reproduce the problem with a simplified model attached here. The fillet/draft will fail on the intersection edge of the concave faces. After tracing into OCC, I found that the problem lies in here. The call site is at here. The function ChFi3d_cherche_edge is only called in three places. The other two places already check for null shape. And based on the while loop exiting condition at the call site, it should be able to deal with null shape as well. Removing the exception throwing in ChFi3d_cherche_edge fixes the draft/fillet problem. Not sure if we should take another look at throwing exceptions in other 'cherche' functions for similar side effect.
Screenshot from 2021-09-19 18-33-18.png
Screenshot from 2021-09-19 18-33-18.png (10.52 KiB) Viewed 1601 times
Attachments
draftfail.FCStd
(21.49 KiB) Downloaded 40 times
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by chennes »

realthunder wrote: Sun Sep 19, 2021 10:38 am I think there is a problem in your patch.
Are you using the version that actually made it into OCCT, or the original submission (collected as a "blobfish" patch by tanderson69)? There was indeed a problem with the original patch, fortunately the OCCT team helped me get it resolved. I haven't looked at the code in a while, but if you were using the real OCCT 7.6 patch, I'll dig back in and figure out what's wrong.

ETA: The real (as-merged) patch can be found here.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
papyblaise
Veteran
Posts: 7877
Joined: Thu Jun 13, 2019 4:28 pm
Location: France

Re: [bug 4543] [crash] on applying fillet or chamfer

Post by papyblaise »

Refine = true : it's works
Attachments
refine.PNG
refine.PNG (9.99 KiB) Viewed 1460 times
Post Reply