Skip to content

crash with firefox logo on svglib 0.9.1, but works on 0.9.0 #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Akuli opened this issue Jun 30, 2019 · 5 comments
Closed

crash with firefox logo on svglib 0.9.1, but works on 0.9.0 #195

Akuli opened this issue Jun 30, 2019 · 5 comments

Comments

@Akuli
Copy link

Akuli commented Jun 30, 2019

Download https://upload.wikimedia.org/wikipedia/commons/6/67/Firefox_Logo%2C_2017.svg to firefox.svg

After pip install svglib==0.9.0 running this produces out.gif as expected, but after installing 0.9.1 it raises an error

from svglib import svglib
from reportlab.graphics.renderPM import drawToPIL, drawToFile

rlg = svglib.svg2rlg('firefox.svg')
drawToFile(rlg, 'out.gif')

Here is the error

Can't handle color: url(#radial-gradient)
Can't handle color: url(#radial-gradient-2)
Can't handle color: url(#linear-gradient)
Can't handle color: url(#radial-gradient-3)
Can't handle color: url(#radial-gradient-4)
Can't handle color: url(#radial-gradient-5)
Can't handle color: url(#radial-gradient-6)
Can't handle color: url(#radial-gradient-7)
Can't handle color: url(#linear-gradient-2)
Can't handle color: url(#linear-gradient-3)
Can't handle color: url(#linear-gradient-4)
Can't handle color: url(#linear-gradient-5)
Can't handle color: url(#linear-gradient-6)
Can't handle color: url(#linear-gradient-7)
Traceback (most recent call last):
  File "asdf.py", line 6, in <module>
    drawToFile(rlg, 'out.gif')
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderPM.py", line 680, in drawToFile
    c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderPM.py", line 666, in drawToPMCanvas
    draw(d, c, 0, 0, showBoundary=showBoundary)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderPM.py", line 51, in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderbase.py", line 205, in draw
    self.drawNode(drawing)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderPM.py", line 108, in drawNode
    self.drawNodeDispatcher(node)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderbase.py", line 286, in drawNodeDispatcher
    self.drawGroup(node)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderbase.py", line 317, in drawGroup
    self.drawNode(node)
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderPM.py", line 111, in drawNode
    self.pop()
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderPM.py", line 60, in pop
    self._tracker.pop()
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderbase.py", line 112, in pop
    reverseDelta[key] = inverse(lastDelta['transform'])
  File "/home/akuli/.local/lib/python3.5/site-packages/reportlab/graphics/renderbase.py", line 16, in inverse
    R = [A[3]/det, -A[1]/det, -A[2]/det, A[0]/det]
ZeroDivisionError: float division by zero
@claudep
Copy link
Collaborator

claudep commented Jun 30, 2019

Thanks for the report, I'm almost certain the problem is in 9184153, where the condition if r != 0 is probably missing before the new introduced line. @ajbrock, maybe you could have a look?

@ajbrock
Copy link
Contributor

ajbrock commented Jun 30, 2019

I think I agree that adding if r!=0 before computing r = 1 / r -1 is a good idea to prevent divide by zero, but I'm not sure I see the error path that would lead to the divide-by-zero in reportlab. If the line in question were computing "1/0 -1" then wouldn't it be outputting an inf or a nan to reportlab? It looks like reportlab is dealing with a transform whose determinant is zero. I don't quite follow the trace logic from the ellipse code to reportlab though, so please feel free to enlighten me =)

@claudep
Copy link
Collaborator

claudep commented Jul 6, 2019

Sorry for wrongly accusing the commit 9184153 for that regression. In fact, the problem arises after 82860fa.

@claudep
Copy link
Collaborator

claudep commented Jul 6, 2019

@Akuli with 0.9.0 do you obtain anything else than a blank page?

@Akuli
Copy link
Author

Akuli commented Jul 12, 2019

I seem to be getting blank page only with 0.9.0 so I think this is a good as it ever was, lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants