[SOLVED][Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Samu
Posts: 51
Joined: Fri Jan 29, 2021 2:16 pm

[SOLVED][Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by Samu »

OS: Ubuntu 20.04.2 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19. Daily
Build type: Release
Branch: unknown
Hash: e8566f22bbeb0b7204e3c45519d0963e8881100b
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)

If I want to postprocess from more than one .FCStd file in one FreeCAD session, the following error is thrown at me:

13:19:23 Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPost.py", line 396, in Activated
(fail, rc, filename) = self.exportObjectsWith(finalpostlist, job)
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPost.py", line 211, in exportObjectsWith
gcode = processor.export(objs, filename, postArgs)
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPostProcessor.py", line 100, in export
return self.script.export(obj, filename, args)
File "/usr/lib/freecad-daily/Mod/Path/PathScripts/post/linuxcnc_post.py", line 197, in export
job = PathUtils.findParentJob(obj)
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathUtils.py", line 444, in findParentJob
if hasattr(i, 'Proxy') and isinstance(i.Proxy, PathJob.ObjectJob):

Cannot access attribute 'Proxy' of deleted object


Just got the error with the two attached FCStd files, but could have been any other file combination as well - the error is thrown at me for a while now.

I just checked and the error is independent of the used postprocessor (checked for linuxcnc, dxf, grbl and two of my own postprocessors).
Attachments
Sound_Fillet.FCStd
(182.42 KiB) Downloaded 41 times
A_Single_Bottom.FCStd
(86.38 KiB) Downloaded 41 times
Last edited by Samu on Wed Mar 24, 2021 8:46 am, edited 1 time in total.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by GeneFC »

I just tried your files, and I did not see any problems as described.

I did find two issues when I tried to simulate in Camotics. One of the output files has all feedrates set to zero. Another has a problem with improperly defined arcs in which the radius and endpoints of the arcs do not match correctly. Neither of these problems would be the cause of the "proxy" error.

If I was to guess, I would say that you have done some manipulation of the Job file(s), perhaps with additions and deletions. I have found that "cancels" and "deletions" sometimes lead to the type of error in the title of this topic.

I suggest that you save the files, close FreeCAD, and reopen the files.

OS: Windows 7 Version 6.1 (Build 7601: SP 1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 (Git)
Build type: Release
Branch: master
Hash: b2ca86d8d72b636011a73394bf9bcdedb3b109b7
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)

Gene
Samu
Posts: 51
Joined: Fri Jan 29, 2021 2:16 pm

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by Samu »

Thank you Gene testing!
When I reopen FreeCAD, postprocessing always works again. Its not about just getting the files postprocessed, but eliminating this error for an improved workflow.

The 'arc' problem comes from the linuxcnc_post. If working in G17, many millcontrols (including linuxcnc) do not like 'K' values in the G-Code. The particular Job contains some arcs in G18.
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by sliptonic »

I have seen this bug and I hate it.

Once the bug occurs, you can't do anything useful in Path. Postprocessing doesn't work on any file. The bug isn't specific to the file. If you close and reopen the document, the problem remains. But if you close and restart FreeCAD, it goes away.

So there's something that happens in the GUI that set up the condition. What we need is a reproducible set of step to trigger it.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by mlampert »

Samu wrote: Tue Mar 23, 2021 12:28 pm I just checked and the error is independent of the used postprocessor (checked for linuxcnc, dxf, grbl and two of my own postprocessors).
Seems you can readily reproduce this issue. Could you change PathUtils.py from

Code: Select all

        if hasattr(i, 'Proxy') and isinstance(i.Proxy, PathJob.ObjectJob):
            return i
to

Code: Select all

        try:
            if hasattr(i, 'Proxy') and isinstance(i.Proxy, PathJob.ObjectJob):
                return i
        except:
            print("object: {}", i.Name)
            raise
reporduce the issue and post the output? There's a chance that i.Name also throws in which case we'll have to find a different way.
Samu
Posts: 51
Joined: Fri Jan 29, 2021 2:16 pm

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by Samu »

Just did a little bit of try and error and now I have a consistent way of reproducing the error with the attached files:

1. start new FC session
2. open both files
3, Postprocess the job in one of the files (does not matter in which)
4. save and close the file you just postprocessed
5. postprocessing the second file throws the error

Is that reproducible for anyone else?

with the changes in PathUtils.py the error looks like this:

19:42:03 Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPost.py", line 396, in Activated
(fail, rc, filename) = self.exportObjectsWith(finalpostlist, job)
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPost.py", line 211, in exportObjectsWith
gcode = processor.export(objs, filename, postArgs)
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPostProcessor.py", line 100, in export
return self.script.export(obj, filename, args)
File "/usr/lib/freecad-daily/Mod/Path/PathScripts/post/linuxcnc_post.py", line 197, in export
job = PathUtils.findParentJob(obj)
File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathUtils.py", line 448, in findParentJob
print("object: {}", i.Name)

Cannot access attribute 'Name' of deleted object
Attachments
Test_proxyerror_2.FCStd
(110.19 KiB) Downloaded 36 times
Test_proxyerror_1.FCStd
(24.66 KiB) Downloaded 33 times
Russ4262
Posts: 953
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by Russ4262 »

Samu wrote: Tue Mar 23, 2021 6:46 pm Just did a little bit of try and error and now I have a consistent way of reproducing the error with the attached files:
...
Afternoon,
I am able to reproduce with:
1. Start FC
2. Open one of files provided in this thread.
3. Load PathWB
4. Select a job and post-process (EDIT: select linuxcnc post from GUI list) and save output
5. Close file, with or without saving.
6. Open another file from this thread
7. Select a job and post-process (EDIT: select linuxcnc post from GUI list) and save output
8. Raise eyebrow at the error.

Making progress on identifying the offending critter, and I found a separate bug while looking for this critter, related to job selection in PathPost module.

Have to step away from FC machine for a while. Will continue and report back when I am able.

EDIT: Updated my error reproduction procedure above. Getting different results if I don't change post processor selection in GUI list, leaving on `centroid` and clicking OK.

Russell

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)
Russ4262
Posts: 953
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by Russ4262 »

Me again.
Performing some more testing. Making more discoveries on producing the error and when/where it occurs. Will report back.

Russell
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by sliptonic »

I don't understand why this is suddenly happening. When the postprocessor tries to look up the job by looking for for the parent of the objects to be posted, it's seems to be trying to find the job of the document that was closed.

I don't understand it but it's easy (and a very good idea) to avoid it.

In the linuxcnc_post.py file,

comment out this line: https://github.com/FreeCAD/FreeCAD/blob ... st.py#L197

Also comment out https://github.com/FreeCAD/FreeCAD/blob ... #L201-L212

This entire section is deprecated because the job doesn't have a 'MachineName' or 'MachineUnits' property anymore and hasn't for a very long time.

This is the only reason the postprocessor is trying to look up the job. It's an entirely worthless call and it's being made for every object being post processed!

The change will have to be made for every postprocessor.
Samu
Posts: 51
Joined: Fri Jan 29, 2021 2:16 pm

Re: [Bug] Postprocessing error 'Cannot access attribute 'Proxy' of deleted object'

Post by Samu »

Works perfectly with the 'worthless call' commented out. Thank you all for your help!
Post Reply