[pypy-issue] [issue1679] Segfault on 32bit pypy

Armin Rigo tracker at bugs.pypy.org
Thu Jan 23 10:24:02 CET 2014


Armin Rigo <armin.rigo at gmail.com> added the comment:

Ok, found it.  You are calling FT_New_Memory_Face() with the font_bytes being a
pointer just returned from PyArg_ParseTuple(..."s#"...), but you're not keeping
alive the object that held that memory.  CPython is "more or less safe" because
you call core.getfont(.., self.font_bytes) and thus keep the font_bytes string
alive as needed --- assuming, reasonably, that nobody does "font.font_bytes =
None" behind your back.  This doesn't work in PyPy because the data in the
font_bytes object is copied from GC memory to non-movable memory before the call
to core.getfont(), and freed afterwards.

I'd suggest that you change this to make the C-level FontObject keep a reference
to the font_bytes, rather than the Python-level FreeTypeFont.

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1679>
________________________________________


More information about the pypy-issue mailing list