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

Fatal Python error for negative radius in ImageFilter.BoxBlur() #6873

Closed
marcelgouka opened this issue Jan 9, 2023 · 2 comments · Fixed by #6874
Closed

Fatal Python error for negative radius in ImageFilter.BoxBlur() #6873

marcelgouka opened this issue Jan 9, 2023 · 2 comments · Fixed by #6874
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@marcelgouka
Copy link

marcelgouka commented Jan 9, 2023

Hi,

Python crashes without an exception when a negative radius is passed into ImageFilter.BoxBlur().
This is the error message using spyder.

Fatal Python error: Aborted

Main thread:
Current thread 0x00007fbab679b740 (most recent call first):
  File "/home/mgouka/miniconda3/envs/bx_gui/lib/python3.9/site-packages/PIL/ImageFilter.py", line 189 in filter
  File "/home/mgouka/miniconda3/envs/bx_gui/lib/python3.9/site-packages/PIL/Image.py", line 1305 in filter
  File "/tmp/ipykernel_28079/2108891280.py", line 1 in <module>


Restarting kernel...

And using python in the standard linux terminal it says:

Segmentation fault (core dumped)

The code below produces the problem.

import numpy as np
from PIL import Image, ImageFilter

img = Image.fromarray(np.ones([100, 100, 3], dtype='uint8'))
img = img.filter(ImageFilter.BoxBlur(-2))
@Yay295
Copy link
Contributor

Yay295 commented Jan 9, 2023

For me it crashes when the filter is used, not when it's created. I haven't looked into it any further than that.

@hugovk hugovk added the Bug Any unexpected behavior, until confirmed feature. label Jan 9, 2023
@hugovk
Copy link
Member

hugovk commented Jan 9, 2023

Yep, it doesn't happen for:

fil = ImageFilter.BoxBlur(-2))

But does for:

fil = ImageFilter.BoxBlur(-2)
img = img.filter(fil)  # <--- here

Here's a suggestion: raise a ValueError when creating a filter with negative radius. We could do so when using the filter, but why not handle it earlier?

Please see PR #6874.

@radarhere radarhere changed the title Fatal python error for negative radius in ImageFilter.BoxBlur() Fatal Python error for negative radius in ImageFilter.BoxBlur() Jan 10, 2023
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants