Ticket #4035 - pocket tool crashes FreeCAD

Here's the place for discussion related to CAM/CNC and the development of the Path module.
User avatar
freman
Posts: 1266
Joined: Tue Nov 27, 2018 10:30 pm

Ticket #4035 - pocket tool crashes FreeCAD

Postby freman » Mon Jun 24, 2019 3:23 pm

Hi,

If I try to create a pocket path on the upper face of this model , it unceremoniously crashes FreeCAD .

model-body.face8

Code: Select all

OS: Linux (LXDE/LXDE)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17119 (Git)
Build type: Release
Branch: master
Hash: e72b48e0cfcf4773e4b6527c74f2bac11ccff1ab
Python version: 2.7.15
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Attachments
housing-crash.FCStd
(18.59 KiB) Downloaded 19 times
Last edited by Kunda1 on Wed Oct 14, 2020 12:36 pm, edited 1 time in total.
Reason: Added ticket number to thread title + ticket name
Russ4262
Posts: 524
Joined: Sat Jun 30, 2018 3:22 pm

Re: pocket tool crashes FreeCAD

Postby Russ4262 » Mon Jun 24, 2019 3:46 pm

freman wrote:
Mon Jun 24, 2019 3:23 pm
Hi,
If I try to create a pocket path on the upper face of this model , it unceremoniously crashes FreeCAD .
I'll load it up and take a look. I'm decompressing Windows 0.19.17108 portable as I type. I'll use it to check it out.

Thanks,
Russ
Russ4262
Posts: 524
Joined: Sat Jun 30, 2018 3:22 pm

Re: pocket tool crashes FreeCAD

Postby Russ4262 » Mon Jun 24, 2019 5:18 pm

Afternoon,
Here is my troubleshooting report using the OS/FC setup pasted at the end of this message.
  1. Opened FC no problem
  2. Opened provided file with immediate error in Report Panel:

    Code: Select all

    No extension found of type 'PartGui::ViewProviderAttachExtension
  3. Switched to Path workbench without error
  4. Clicked on top face of model: Face8
  5. Clicked on Pocket Shape icon (red circle in attached image)
  6. Selected "T8: 10mm 2 flute endmill" for tool controller and clicked OK
  7. Pocket Shape settings appear in Tasks tab in Combo View with errors in Report Panel:

    Code: Select all

    PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
    PathPocketShape.ERROR: list index out of range
    PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
    PathPocketShape.ERROR: list index out of range
    Exception (Mon Jun 24 11:31:31 2019): Access violation  
    PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
    PathPocketShape.ERROR: list index out of range
    
    These errors are related to `extensions` feature and should not be the source of any failure. Another observation is that the stock appears directly above the model in the viewport rather than enclosing it as it should. (see image) This could be a source of a problem in path operations.
  8. Click OK with no changes to settings.
  9. Operation produces expected paths - too many steps(layers) is due to stock setting on top of model, rather than enclosing it. (see image)
After the above steps, I edited the 'house-Job'. In the 'Setup' tab I clicked the 'Refresh' button in the 'Layout' section. I clicked OK to save changes. I selected the 'Pocket_Shape' object created in steps above and recomputed it. This yielded the proper paths displayed in the last image with only one step(layer).

I did not encounter any crashes or fatal errors.
This leads to a suspicion that the crash you are experiencing might be related to one or more of the following:
  • differences in OS
  • FC version differences (even though mine is quite close to yours) - a new commit after my version might be to cause
  • the error I received in step two above that had no noticeable effects on my machine other than the textual error message
  • (UPDATE) different Python or Qt versions
  • something else entirely different like solar flares...
Best wishes,
Russ

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17108 (Git)
Build type: Release
Branch: master
Hash: e632e9feb8a9dd56d5a879f2afef636cc159095e
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)
Attachments
housing-crash_1a.png
Pocket Shape tool icon
housing-crash_1a.png (155.11 KiB) Viewed 559 times
housing-crash_1b.png
stock above model
housing-crash_1b.png (140.9 KiB) Viewed 559 times
housing-crash_1c.png
expected paths generated
housing-crash_1c.png (146.36 KiB) Viewed 559 times
housing-crash_1d.png
recomputed paths after refreshing stock in Job settings
housing-crash_1d.png (153.89 KiB) Viewed 559 times
Last edited by Russ4262 on Tue Jun 25, 2019 6:11 am, edited 2 times in total.
User avatar
freman
Posts: 1266
Joined: Tue Nov 27, 2018 10:30 pm

Re: pocket tool crashes FreeCAD

Postby freman » Tue Jun 25, 2019 5:41 am

Thanks for your report and testing. I did not try to work around or fix the problem because it seems something that creates an all out crash needs fixing, even if some oddities like the boundaries maybe the cause, errors should be trapped and not crash FreeCAD.

This may be linked to "phantom paths " bug and I may be guilty of "going to the opera" before/after defining the job.

IIRC what I did here was create the sketch , pad +ve, add job, noticed that origin was not right. Went back and changed pad to "reversed", came back to same job ( ie not deleting and starting fresh job ). This presumably will no longer cause problems when Russ' PR is merged.

I know I keep moaning about lack of error checking, maybe this common practice in python, but even if something like phantom paths bug is setting the scene for this to happen it seems to me to show that some more low level error checking is needed instead of letting stuff assume everything is OK.

I'd like some thoughts on this from those writing the python code in FreeCAD.

Code: Select all

Exception (Mon Jun 24 11:31:31 2019): Access violation 
OS differences likely explain different results. It seem Linux takes illegal memory accesses more seriously than Windows.

Code: Select all

PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
PathPocketShape.ERROR: list index out of range
PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
PathPocketShape.ERROR: list index out of range
Program received signal SIGSEGV, Segmentation fault.
#0  /lib64/libpthread.so.0(+0x13070) [0x7f3258199070]
#1  /usr/local/lib64/libCoin.so.80(cc_rbptree_insert+0xa) [0x7f32586a133a]
#2  0x7f325880bf52 in SoChildList::append(SoNode*) from /usr/local/lib64/libCoin.so.80+0x22
#3  0x7f3258852333 in SoGroup::addChild(SoNode*) from /usr/local/lib64/libCoin.so.80+0x43
#4  /usr/lib/python2.7/site-packages/pivy/_coin.so(+0x51440a) [0x7f32349a140a]
#5  /lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8f3b) [0x7f325919f14b]
#6  /lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x7f9c) [0x7f325919e1ac]
#7  /lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712) [0x7f325919f902]
#8  /lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c) [0x7f325919c53c]
#9  /lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712) [0x7f325919f902]
#10  /lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c) [0x7f325919c53c]
#11  /lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x712) [0x7f325919f902]
#12  /lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x632c) [0x7f325919c53c]
#13  /lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x7f9c) [0x7f325919e1ac]
Opened provided file with immediate error in Report Panel:

Code: Select all

No extension found of type 'PartGui::ViewProviderAttachExtension
I get no error on opening the file. The only thing I have changed from building master a couple of days ago, is replacing PathSurface.py t3 with w3 , and I have the extended tools enabled to get the 3D pocket tool ( which is not used here ).

I think that is due to you testing a virgin FC. I had the 3D pocket enabled.
Last edited by freman on Tue Jun 25, 2019 6:16 pm, edited 1 time in total.
User avatar
freman
Posts: 1266
Joined: Tue Nov 27, 2018 10:30 pm

Re: pocket tool crashes FreeCAD

Postby freman » Tue Jun 25, 2019 6:40 am

Code: Select all

       try:
            l0 = (ePts[0] - endPts[0]).Length
        except Exception as ee:
            PathLog.error("extendWire(): (ePts[0] - endPts[0]).Length")
            PathLog.error(ee)
            return False
        else:
It seems that prior to the segfault the error has been trapped but it not aborted in the caller when it fails.
User avatar
freman
Posts: 1266
Joined: Tue Nov 27, 2018 10:30 pm

Re: pocket tool crashes FreeCAD

Postby freman » Tue Jun 25, 2019 4:49 pm

Just deleted the job, created a new one with the stock bounds showing correctly. Still get the same crash.
User avatar
Kunda1
Posts: 8687
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4035 - pocket tool crashes FreeCAD

Postby Kunda1 » Wed Oct 14, 2020 12:38 pm

Added ticket number to thread title, issue #4035.
Inquiring if this is intended to be fixed for 0.19 or bumped to next version ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
Russ4262
Posts: 524
Joined: Sat Jun 30, 2018 3:22 pm

Re: Ticket #4035 - pocket tool crashes FreeCAD

Postby Russ4262 » Thu Oct 15, 2020 2:52 am

Kunda1 wrote:
Wed Oct 14, 2020 12:38 pm
... Inquiring if this is intended to be fixed for 0.19 or bumped to next version ?
Sir,
This bug might be fixed via some of the other fixes since 2019. I downloaded the original file and attempted to pocket the top surface indicated in this thread and it creates a path without error. Perhaps others could confirm whether the error remains or has been fixed.

Russell

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22411 (Git)
Build type: Release
Branch: master
Hash: d4519d5aec15bc08f029da5ed15410a494b57b2c
Python version: 3.8.5
Qt version: 5.12.6
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)
User avatar
Kunda1
Posts: 8687
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #4035 - pocket tool crashes FreeCAD

Postby Kunda1 » Thu Oct 15, 2020 11:33 am

Thank you sir. ;)
Russ4262 wrote:
Thu Oct 15, 2020 2:52 am
Version: 0.19.22411 (Git)
Just something to point out, I noticed that you're using an older 0.19 revision. Current revision is 22670, FYI
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
GeneFC
Posts: 1654
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Ticket #4035 - pocket tool crashes FreeCAD

Postby GeneFC » Thu Oct 15, 2020 2:39 pm

Russ4262 wrote:
Thu Oct 15, 2020 2:52 am
Perhaps others could confirm whether the error remains or has been fixed.
The original file has some issues with the stock placement, but I was able to use the pocket operation without error.

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22670 (Git)
Build type: Release
Branch: master
Hash: 12155f4aab09047c5697db0c1b3cf93b02edda03
Python version: 3.8.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

Gene