rougier / freetype-py

Python binding for the freetype library
Other
298 stars 88 forks source link

`segfault` with version `2.4.0` #172

Open miguelsousa opened 1 year ago

miguelsousa commented 1 year ago

Font Bakery has freetype-py as a dependency which is used on one of its checks.

We've received a report of that check failing with a segfault for variable TrueType fonts when freetype-py version 2.4.0 is installed. The crash doesn't happen with version 2.3.0.

I've ran the freetype-py code (snippet below) in isolation but couldn't get it to segfault.

import freetype

face = freetype.Face("SourceSerif4Variable-Italic.ttf")
face.set_char_size(48 * 64)
face.load_char("✅")

Could this be related with #169 ?

miguelsousa commented 1 year ago

I tried the patch proposed in #171 and the segfault still happens. Commenting out the Face.__del__ method also didn't fix it.

HinTak commented 1 year ago

You do know 2.4.0 is about a decade old, right? I was adapting 2.6.x for the beginning of fontval, which was 2016, 7 years ago.

Edit: sorry , wasn't in touch with freetype-py version. In general, segfault is a freetype problem; strange exception is a freetype-py problem.

miguelsousa commented 1 year ago

You do know 2.4.0 is about a decade old

I'm talking about freetype-py v2.4.0 which was release in May 4, 2023, not Python 2.4.0.

HinTak commented 1 year ago

I think somebody else also updated the bundled freetype version recently, if you are using wheel or whatever it is called, rather than the system-wide freetype on most Linux machines.

miguelsousa commented 1 year ago

I don't have freetype installed, and as I mentioned above, rolling back freetype-py to v2.3.0 no longer causes the segfault. Is there a way to tell which version of freetype is bundled with each freetype-py?

miguelsousa commented 1 year ago

Following the release notes of v2.4.0, I found this commit which updated freetype from 2.12.0 to 2.13.0.

HinTak commented 1 year ago

You can query from within freetype-py - it is returned by FT_Version(), or something of similar name.

HinTak commented 1 year ago

Some ways of installing freetype-py also build a bundled freetype. The version is controlled by https://github.com/rougier/freetype-py/blob/master/setup-build-freetype.py so you might want to check that file's history. Regardless, putting something like FT_Version() inside your python code might be a better way of knowing what version of freetype you are using.

HinTak commented 1 year ago

It is just freetype.version(), according to the code: https://github.com/rougier/freetype-py/blob/ccd4f5fca0fb1dd69e40b2966db60139ec1c49da/freetype/__init__.py#L85

miguelsousa commented 1 year ago

The crash only happens on macOS.