Open
Description
What did you do?
In a multi-page TIFF 8-bit image seek back to index 0 from any index greater than 0.
What did you expect to happen?
The first index is read and the array can be accessed.
What actually happened?
Process ends unexpectedly with signal 11:SIGSEGV
What are your OS, Python and Pillow versions?
- OS: Ubuntu 24.04.2 LTS
- Python: 3.12.10
- Pillow: 11.x
- NumPy: 2.1.3
--------------------------------------------------------------------
Pillow 11.0.0
Python 3.12.10 (main, May 18 2025, 14:08:06) [GCC 13.3.0]
--------------------------------------------------------------------
Python executable is /home/myuser/.pyenv/versions/pillow-segfault/bin/python3
Environment Python files loaded from /home/myuser/.pyenv/versions/pillow-segfault
System Python files loaded from /home/myuser/.pyenv/versions/3.12.10
--------------------------------------------------------------------
Python Pillow modules loaded from /home/myuser/.pyenv/versions/pillow-segfault/lib/python3.12/site-packages/PIL
Binary Pillow modules loaded from /home/myuser/.pyenv/versions/pillow-segfault/lib/python3.12/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.0.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- JPEG support ok, compiled for libjpeg-turbo 3.0.4
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.13, harfbuzz 10.0.1
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
#!/usr/bin/env python3
import numpy as np
from PIL import Image
def _get_np_array(img, seek_index, dtype):
img.seek(seek_index)
return np.asarray(img, dtype=dtype)
if __name__ == '__main__':
image_path = './11-pages.tif'
image_shape = (336, 256)
pil_img = Image.open(image_path)
assert pil_img.n_frames == 11
array = _get_np_array(pil_img, 1, np.uint8)
assert array.shape == (336, 256)
array = _get_np_array(pil_img, 2, np.uint8)
assert array.shape == (336, 256)
array = _get_np_array(pil_img, 1, np.uint8)
assert array.shape == (336, 256)
##########################################################################
# this call will result in a seg_fault, when attempting to get the array #
##########################################################################
array = _get_np_array(pil_img, 0, np.uint8)
assert array.shape == (336, 256)
The provided example works in Pillow 10.x.