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

out of memory when processing this GIF #2402

Closed
mohanson opened this issue Feb 14, 2017 · 2 comments
Closed

out of memory when processing this GIF #2402

mohanson opened this issue Feb 14, 2017 · 2 comments
Labels
Bug Any unexpected behavior, until confirmed feature. GIF

Comments

@mohanson
Copy link

mohanson commented Feb 14, 2017

source: http://lavender.b0.upaiyun.com/ex.gif

example.jpg

import PIL
import PIL.Image

im = PIL.Image.open('example.gif')
print(im.size)
print(im.n_frames)  # will crash
[root /tmp] python3 run.py 
(320, 240)
Killed

The problem appear on this line https://github.com/python-pillow/Pillow/blob/master/PIL/GifImagePlugin.py#L261, self.dispose_extent is very huge.

env: python3.5 on linux, free mem is 2G.

thanks.

@mohanson
Copy link
Author

any idea?

@wiredfool
Copy link
Member

Well, as you've noted, the dispose_extent of frame 90 is rather large:

(Pdb) self.dispose_extent
(37042, 49425, 90174, 109354)
(Pdb) frame
90

This is fed to crop, which ultimately returns a new image. Or, tries to, as that's a rather large image.

Any potential fix for #2383 could interact badly with this, as the dispose_extent winds up being the tile extents as well.

Crop should really have the DecompressionBomb warning applied, as it can increase the size of the image. But in this case, we're calling into the core image object crop, not Image.crop, so we'd need to either hoist it to a python level function or call the decompression_bomb_check from the C layer.

@wiredfool wiredfool added Bug Any unexpected behavior, until confirmed feature. GIF labels Feb 17, 2017
@wiredfool wiredfool mentioned this issue Feb 17, 2017
1 task
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. GIF
Projects
None yet
Development

No branches or pull requests

2 participants