fdintino / pillow-avif-plugin

A pillow plugin that adds avif support via libavif
BSD 2-Clause "Simplified" License
90 stars 13 forks source link

Crash when using aom, speed=4, on macos #59

Closed jnoring-pw closed 3 months ago

jnoring-pw commented 3 months ago

macOS 14.4.1 (23E224), Apple M3 Max, python 3.12, pillow-avif-plugin 1.4.4 (cannot reproduce with 1.4.3)

When running the following code, I hit some sort of exception down in native land:

import pillow_avif
from PIL import Image
image = Image.open("/Users/jnoring/Downloads/blah.png")

# This is fine
image.save("/Users/jnoring/Downloads/blah.avif", codec="aom")

# Boom
image.save("/Users/jnoring/Downloads/blah.avif", codec="aom", speed=4)

Here's the dump file: crash.txt

And the offending thread:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   _avif.cpython-312-darwin.so            0x1058e60a4 compute_stats_win5_neon + 652
1   _avif.cpython-312-darwin.so            0x1058e5eb4 compute_stats_win5_neon + 156
2   _avif.cpython-312-darwin.so            0x1058e49f0 av1_compute_stats_neon + 1628
3   _avif.cpython-312-darwin.so            0x105800494 search_wiener + 488
4   _avif.cpython-312-darwin.so            0x1057fff10 av1_pick_filter_restoration + 2804
5   _avif.cpython-312-darwin.so            0x10579c798 encode_with_recode_loop_and_filter + 8736
6   _avif.cpython-312-darwin.so            0x105794750 av1_encode + 3684
7   _avif.cpython-312-darwin.so            0x105788e54 av1_encode_strategy + 6944
8   _avif.cpython-312-darwin.so            0x105795bf4 av1_get_compressed_data + 464
9   _avif.cpython-312-darwin.so            0x1057395d4 encoder_encode + 3780
10  _avif.cpython-312-darwin.so            0x1053a7c5c aom_codec_encode + 180
11  _avif.cpython-312-darwin.so            0x10513204c aomCodecEncodeImage + 4196
12  _avif.cpython-312-darwin.so            0x10512bd40 avifEncoderAddImageInternal + 1868
13  _avif.cpython-312-darwin.so            0x10512b5e0 avifEncoderAddImage + 72
14  _avif.cpython-312-darwin.so            0x1051134c8 _encoder_add + 552
15  Python                                 0x103f3dde4 method_vectorcall_VARARGS + 132
16  Python                                 0x104073ba0 _PyEval_EvalFrameDefault + 44872
17  Python                                 0x104068940 PyEval_EvalCode + 304
18  Python                                 0x1040e8ddc run_mod + 176
19  Python                                 0x1040e73b4 PyRun_InteractiveOneObjectEx + 632
20  Python                                 0x1040e6b0c _PyRun_InteractiveLoopObject + 156
21  Python                                 0x1040e6994 _PyRun_AnyFileObject + 76
22  Python                                 0x1040e70c0 PyRun_AnyFileExFlags + 68
23  Python                                 0x104114eb8 pymain_run_stdin + 164
24  Python                                 0x104114424 Py_RunMain + 956
25  Python                                 0x10411485c pymain_main + 36
26  Python                                 0x1041148d4 Py_BytesMain + 40
27  dyld                                   0x19938a0e0 start + 2360
jnoring-pw commented 3 months ago

One other detail: this definitely is a macOS thing. I have no reproduction on x86/arm linux.

jnoring-pw commented 3 months ago

Thanks @fdintino !

fdintino commented 3 months ago

Once the build finishes in CI I'll be uploading the 1.4.6 release to PyPI with this fix. When you have a chance could you confirm that it does in fact fix the issue? Thanks.

fdintino commented 3 months ago

okay, I've uploaded the release.

jnoring-pw commented 3 months ago

And, confirmed: no crash, and all my tests pass. Thanks so much, @fdintino