HPGL Output crashes

Bug #487052 reported by TentacleGuy
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Incomplete
Medium
Unassigned

Bug Description

If I try to save my work as a hpgl-file for a vinyl cutter, the output plugin doesn't work:

Traceback (most recent call last):
  File "/usr/local/share/inkscape/extensions/hpgl_output.py", line 84, in <module>
    e.affect()
  File "/usr/local/share/inkscape/extensions/inkex.py", line 207, in affect
    self.effect()
  File "/usr/local/share/inkscape/extensions/hpgl_output.py", line 72, in effect
    cspsubdiv.cspsubdiv(p, self.options.flat)
  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 17, in cspsubdiv
    subdiv(sp,flat)
  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 38, in subdiv
    subdiv(sp,flat,i)
  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 38, in subdiv
    subdiv(sp,flat,i)

[...]

  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 38, in subdiv
    subdiv(sp,flat,i)
  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 29, in subdiv
    subdiv(sp,flat,i+1)
  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 26, in subdiv
    m = maxdist(b)
  File "/usr/local/share/inkscape/extensions/cspsubdiv.py", line 12, in maxdist
    return max(s1.distanceToPoint(p1),s1.distanceToPoint(p2))
  File "/usr/local/share/inkscape/extensions/ffgeom.py", line 88, in distanceToPoint
    return self.perpDistanceToPoint(p)
  File "/usr/local/share/inkscape/extensions/ffgeom.py", line 90, in perpDistanceToPoint
    len = self.length()
  File "/usr/local/share/inkscape/extensions/ffgeom.py", line 97, in length
    return math.sqrt((self.delta_x() ** 2) + (self.delta_y() ** 2))
  File "/usr/local/share/inkscape/extensions/ffgeom.py", line 66, in delta_x
    return self[1]['x'] - self[0]['x']
RuntimeError: maximum recursion depth exceeded

I tried the inkscpae 4.6 included in ubuntu and the inkscape-47 -branch from the SVN repository, same error.

Tags: exporting hpgl
description: updated
su_v (suv-lp)
tags: added: exporting hpgl
Revision history for this message
jazzynico (jazzynico) wrote :

Hi,
Could you please attach the file which leads to the crash, so that we can try to reproduce it?
Thanks!

Revision history for this message
TentacleGuy (neuhaus-dodekatex) wrote :

Interesting - in the current version save as "HP...(AutoCAD) (*.plt)" works, but HP (*.hpgl) crashes as described.

Revision history for this message
jazzynico (jazzynico) wrote :

Bug confirmed on Ubuntu 9.10, Inkscape 0.47pre4.

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Chris Andreae (chris-neko) wrote :

 The bug is in an needlessly tail-recursive function subdiv() in cspsubdiv.py, which overflows the execution stack on large input. I attach a patch which simply converts it to a loop. The original control-flow is preserved, including the odd termination by exception.

Revision history for this message
TentacleGuy (neuhaus-dodekatex) wrote :

I tried your patch - and no error occured.

But - no file was written either....

Revision history for this message
TentacleGuy (neuhaus-dodekatex) wrote :

Holy S*** - After a while my linux began swapping .....

python tried to get more than some GB of RAM.....

jazzynico (jazzynico)
Changed in inkscape:
importance: Undecided → Medium
status: Confirmed → In Progress
Revision history for this message
Chris Andreae (chris-neko) wrote :

Also noticed that HPGL output doesn't apply any transform attributes to the paths, which results in incorrect sizing/layout. This probably should be a separate bug. Attached a quick patch to find and apply them. I don't know Inkscape well enough to know if this is the right thing to do, or sufficient, but it passes the 'seems to work on my test document' test. ;)

Revision history for this message
jjbarrows (jjbarrows) wrote :

still occurs in Lucid using normal install of version .47 and PPA install of version .48 (as at 3/sept/2010)

Revision history for this message
su_v (suv-lp) wrote :

@Chris-Andreae - an improved version of HPGL output, adding support for transform elements, has been recently committed in rev. rev 9689 (see Bug #600472 “file saves with file types that are written in python have missing object or misplaced objects (dxf and hpgl)”: <https://bugs.launchpad.net/inkscape/+bug/600472>)

Revision history for this message
Alvin Penner (apenner) wrote :

running Windows XP and Inkscape 0.48.0 r9654 (Aug 16 2010), I get the attached file, which appears to be okay. (Not sure if the precision of the rendering is sufficiently good.)

could you try the latest version and see if it helps. The source code is hpgl_output.py, available at : Bug 600472, comment 13.

while doing the test I ran into a separate bug. If I select "Mirror Y axis", I get a Python crash with the message:
ValueError: invalid literal for float(): 100%
apparently caused by the presence of the % sign. Will try to come up with a patch for that shortly.

Revision history for this message
Alvin Penner (apenner) wrote :

patch for % sign committed to bzr rev 9742

Revision history for this message
su_v (suv-lp) wrote :

Issue as originally reported:
> If I try to save my work as a hpgl-file for a vinyl cutter,
> the output plugin doesn't work:
> (…)
> File "/usr/local/share/inkscape/extensions/ffgeom.py", line 66, in delta_x
> return self[1]['x'] - self[0]['x']
> RuntimeError: maximum recursion depth exceeded

seems the same issue as reported in
Bug #340123 “Effects - Modify Path - Flatten Beziers fails on complicated paths with small flatness parameter”
<https://bugs.launchpad.net/inkscape/+bug/340123>

Revision history for this message
Alvin Penner (apenner) wrote :

a modified version of the file cspsubdiv.py has been posted at:
https://bugs.launchpad.net/inkscape/+bug/340123/comments/5
this should fix the crash. The method used is somewhat similar to that proposed in comment 2 above, namely replace the recursive call with a while loop.

in order to implement this, you will need to copy the file cspsubdiv.py into the directory \Inkscape\share\extensions\ to replace the file that is there. you may want to make a backup of the original file, just in case.
as usual, any feedback would be welcome...

Revision history for this message
Alvin Penner (apenner) wrote :

sorry, I meant comment 4 above, by Chris

Alvin Penner (apenner)
Changed in inkscape:
status: In Progress → Incomplete
su_v (suv-lp)
tags: added: backport-proposed
tags: removed: backport-proposed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.