enthought / pyface

pyface: traits-capable windowing framework
Other
105 stars 55 forks source link

Segfaults on PIL image tests #1207

Closed corranwebster closed 1 year ago

corranwebster commented 1 year ago

Environment

OS: Mac Python version: 3.8 Toolkit: Qt Qt API: PySide6 (may occur on others, not tested)

Description

I am seeing a test Pyface segfault only on EDM-based MacOS runs of Python 3.8, PySide6 on GitHub; I can’t reproduce locally even when running the same setup.

The failure is happening in a call out to PIL to get the bytes of an image, and is working on all other platforms. I am wondering if this is an issue with pillow_simd on mac, as it doesn’t happen with a pip-installed pillow.


Current thread 0x000000010cb94600 (most recent call first):
  File "/Users/runner/work/pyface/pyface/.edm/envs/pyface-test-3.8-pyside6/lib/python3.8/site-packages/PIL/Image.py", line 728 in tobytes
  File "/Users/runner/work/pyface/pyface/.edm/envs/pyface-test-3.8-pyside6/lib/python3.8/site-packages/PIL/ImageQt.py", line 168 in _toqclass_helper
  File "/Users/runner/work/pyface/pyface/.edm/envs/pyface-test-3.8-pyside6/lib/python3.8/site-packages/PIL/ImageQt.py", line 197 in __init__
  File "/Users/runner/work/pyface/pyface/.edm/envs/pyface-test-3.8-pyside6/lib/python3.8/site-packages/pyface/ui/qt4/pil_image.py", line 42 in create_image
  File "/Users/runner/work/pyface/pyface/.edm/envs/pyface-test-3.8-pyside6/lib/python3.8/site-packages/pyface/i_pil_image.py", line 55 in create_bitmap
  File "/Users/runner/work/pyface/pyface/.edm/envs/pyface-test-3.8-pyside6/lib/python3.8/site-packages/pyface/tests/test_pil_image.py", line 53 in test_create_bitmap

Steps to Reproduce

Run GitHub CI on Python 3.8/PySide6

itziakos commented 1 year ago

This is due to missing AVX2 support. Most of the cp38 math/scientific packages expect an x86_64 CPU with AVX/AVX2 support. You will also see similar problems when trying to use an EDM cp38 environment through "rosetta" on an Apple Silicon system.

corranwebster commented 1 year ago

For future reference, this snippet will check for the availability of AVX2 on a mac:

process = run(['sysctl', 'machdep.cpu.leaf7_features'], capture_output=True, check=True)
has_avx2 = (b"AVX2" in process.stdout.split())