Skip to content
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

Crash after calling arc with the width parameter #4005

Closed
jonha892 opened this issue Aug 2, 2019 · 5 comments · Fixed by #4014
Closed

Crash after calling arc with the width parameter #4005

jonha892 opened this issue Aug 2, 2019 · 5 comments · Fixed by #4014
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects

Comments

@jonha892
Copy link

jonha892 commented Aug 2, 2019

Hi,

What did you do?
I get an error if I use the width argument of the arc function. It works fine if I leave out the argument.
I call the function like this:
draw.arc([0+offset/2, 0+offset/2,i_w, i_h], a_s, a_e, fill=c, width=8)

What did you expect to happen?
This should work, since it worked on a different machine 2 months ago

What actually happened?
The script crashes without an error message. I used the python tracer module and it just stops after:

ImageDraw.py(111):                 if self.palette and not isinstance(ink, numbers.Number):
ImageDraw.py(113):                 ink = self.draw.draw_ink(ink, self.mode)
ImageDraw.py(114):             if fill is not None:
ImageDraw.py(120):         return ink, fill
ImageDraw.py(125):         if ink is not None:
ImageDraw.py(126):             self.draw.draw_arc(xy, start, end, ink, width)

What versions of Pillow and Python are you using?

  • Python 3.7.3
  • PIL 6.1.0
  • Windows 10
  • anaconda package manager

Is this a local problem or is it a problem with PIL 6.1? I remember it working when I used:

  • Python 3.6.8,
  • PIL: 5.4
  • PIP
  • Linux
@radarhere
Copy link
Member

Pillow 6.1.0 did include a change to this function - #3824 - so it's possible that something changed.

To help with reproducibility, could you provide a self-contained example? It's conceivable that the specific values you're using for offset etc. are triggering the problem.

@radarhere radarhere added this to In progress in Pillow Aug 2, 2019
@jonha892
Copy link
Author

jonha892 commented Aug 3, 2019

Sure, here is a self-contained example that crashes on my system:

from PIL import Image, ImageDraw
im = Image.new('RGB', (640, 640))
draw = ImageDraw.Draw(im)
draw.arc([0+0/2, 0+0/2, 640.0, 640.0], 72.0, 128.5, fill='#1890ff', width=8)
print('Drew an arc...')

I used the actual values where the bug occurs.
I do draw over the bounds of the image. However, I assumed that it should behave like other functions that allow out-of-bound drawing.

radarhere added a commit to radarhere/Pillow that referenced this issue Aug 3, 2019
@cgohlke
Copy link
Contributor

cgohlke commented Aug 6, 2019

This should fix the crash:

diff --git a/src/libImaging/Draw.c b/src/libImaging/Draw.c
index 559be1b0..dee7c524 100644
--- a/src/libImaging/Draw.c
+++ b/src/libImaging/Draw.c
@@ -834,7 +834,7 @@ ellipse(Imaging im, int x0, int y0, int x1, int y1,

         // Build edge list
         // malloc check UNDONE, FLOAT?
-        maxEdgeCount = end - start;
+        maxEdgeCount = ceil(end - start);
         if (inner) {
             maxEdgeCount *= 2;
         }

@radarhere radarhere moved this from In progress to Review/QA in Pillow Aug 6, 2019
@radarhere
Copy link
Member

Thanks @cgohlke

I've created PR #4014 with the fix.

@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Aug 6, 2019
Pillow automation moved this from Review/QA to Closed Sep 5, 2019
@hugovk
Copy link
Member

hugovk commented Sep 5, 2019

Thanks all, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

4 participants