Bug 1706450

Summary: "SystemError: tile cannot extend outside image" on s390x
Product: [Fedora] Fedora Reporter: Elliott Sales de Andrade <quantum.analyst>
Component: python-pillowAssignee: Sandro Mani <manisandro>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: hannsj_uhl, manisandro, mhroncok, miminar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-03 15:06:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 467765, 1701609, 1701932, 1702273, 1706300, 1715262    

Description Elliott Sales de Andrade 2019-05-04 22:34:22 UTC
Description of problem:
I am trying to update a few packages (python-matplotlib [1] and python-pikepdf [2]), but they are failing on s390x with "SystemError: tile cannot extend outside image". I have not attempted to update matplotlib on F30, but at least pikepdf continues to work [3] on F30 with its version of pillow.


Version-Release number of selected component (if applicable):
6.0.0-1.fc31


Steps to Reproduce:
1. Build python-matplotlib or python-pikepdf on Rawhide


Actual results:
/usr/lib64/python3.7/site-packages/PIL/Image.py:2007: in save
    save_handler(self, fp, filename)
/usr/lib64/python3.7/site-packages/PIL/PngImagePlugin.py:896: in _save
    [("zip", (0, 0)+im.size, 0, rawmode)])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
im = <PIL.Image.Image image mode=RGBA size=800x600 at 0x3FF8EA5C2B0>
fp = <PIL.PngImagePlugin._idat object at 0x3ff8eade160>
tile = [('zip', (0, 0, 800, 600), 0, 'RGBA')], bufsize = 65536
    def _save(im, fp, tile, bufsize=0):
        """Helper to save image based on tile list
    
        :param im: Image object.
        :param fp: File object.
        :param tile: Tile list.
        :param bufsize: Optional buffer size
        """
    
        im.load()
        if not hasattr(im, "encoderconfig"):
            im.encoderconfig = ()
        tile.sort(key=_tilesort)
        # FIXME: make MAXBLOCK a configuration parameter
        # It would be great if we could have the encoder specify what it needs
        # But, it would need at least the image size in most cases. RawEncode is
        # a tricky case.
        bufsize = max(MAXBLOCK, bufsize, im.size[0] * 4)  # see RawEncode.c
        if fp == sys.stdout:
            fp.flush()
            return
        try:
            fh = fp.fileno()
            fp.flush()
        except (AttributeError, io.UnsupportedOperation):
            # compress to Python file-compatible object
            for e, b, o, a in tile:
                e = Image._getencoder(im.mode, e, a, im.encoderconfig)
                if o > 0:
                    fp.seek(o)
>               e.setimage(im.im, b)
E               SystemError: tile cannot extend outside image
/usr/lib64/python3.7/site-packages/PIL/ImageFile.py:496: SystemError


Expected results:
Image should be saved like on the other architectures.


Additional info:
[1] https://koji.fedoraproject.org/koji/taskinfo?taskID=34628582
[2] https://koji.fedoraproject.org/koji/taskinfo?taskID=34609431
[3] https://koji.fedoraproject.org/koji/taskinfo?taskID=34205304

Comment 1 Sandro Mani 2019-05-09 13:08:38 UTC
Taken upstream

Comment 2 Elliott Sales de Andrade 2019-06-01 04:42:12 UTC
I believe this should fix it: https://src.fedoraproject.org/rpms/python-pillow/pull-request/3