Skip to content

Segmentation Fault when decoding PNG on macOS 10.14 #8750

@arisolt

Description

@arisolt

What did you do?

I've come across this bug while using pytautogui.screenshot(). By debugging it, I've narrowed it down to this call: decoder.decode(b) inside Image.load(). This call runs successfully when the image is a JPEG format, but not when it's PNG (the latter is the default format used by the screenshot utility on macOS).

For now, I've resolved the problem by downgrading Pillow to 7.2, which was the last version tested on macOS 10.14 according to https://pillow.readthedocs.io/en/latest/installation/platform-support.html

What actually happened?

Python crashes with Segmentation fault: 11 on this line inside Image.load():

n, err_code = decoder.decode(b)

Jumping to the definition of decode() shows that the only instruction is to raise "NotImplementedError", with the message "unvailable in base decoder".

What are your OS, Python and Pillow versions?

  • OS: macOS 10.14.6
  • Python: 3.11.4
  • Pillow: 11.1.0
--------------------------------------------------------------------
Pillow 11.1.0
Python 3.11.4 (main, Jun 23 2023, 05:06:34) [Clang 10.0.1 (clang-1001.0.46.4)]
--------------------------------------------------------------------
Python executable is /usr/local/opt/[email protected]/bin/python3.11
System Python files loaded from /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.11
--------------------------------------------------------------------
Python Pillow modules loaded from /usr/local/lib/python3.11/site-packages/PIL
Binary Pillow modules loaded from /usr/local/lib/python3.11/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.1.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.5.0
--- JPEG support ok, compiled for libjpeg-turbo 3.1.0
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.3
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1.zlib-ng, compiled for zlib-ng 2.2.2
--- LIBTIFF support ok, loaded 4.6.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.1, fribidi 1.0.11, harfbuzz 10.1.0
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
from PIL import Image

img = Image.open("image.png") 
img.load()

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions