[PyQt] Segfault with QRawFont

Kovid Goyal kovid at kovidgoyal.net
Sun Oct 28 10:08:59 GMT 2012

The backtrace is below. Looks to me like the QRawFont object is being
released after Qt has already released the FreeType library, leading to
the segfault. The workaround is to ensure that all QRawFont objects are
deleted before Py_Finalize() is called. I dont know if there is more
elegant way to fix this in PyQt.

#0  0x00007ffff4061e3a in freeServerGlyphSet (id=39845946, this=<optimized out>) at text/qfontengine_x11.cpp:1146
#1  QFontEngineX11FT::freeServerGlyphSet (this=0xa922f0, id=39845946) at text/qfontengine_x11.cpp:1141
#2  0x00007ffff4068e89 in QFontEngineFT::freeGlyphSets (this=0xa922f0) at text/qfontengine_ft.cpp:658
#3  0x00007ffff4061ccb in QFontEngineX11FT::~QFontEngineX11FT (this=0xa922f0, __in_chrg=<optimized out>) at text/qfontengine_x11.cpp:1127
#4  0x00007ffff4061d09 in QFontEngineX11FT::~QFontEngineX11FT (this=0xa922f0, __in_chrg=<optimized out>) at text/qfontengine_x11.cpp:1128
#5  0x00007ffff405f0ef in QRawFontPrivate::cleanUp (this=0xa5c290) at text/qrawfont.cpp:699
#6  0x00007ffff405f194 in ~QRawFontPrivate (this=0xa5c290, __in_chrg=<optimized out>) at text/qrawfont_p.h:94
#7  ~QExplicitlySharedDataPointer (this=<optimized out>, __in_chrg=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qshareddata.h:166
#8  ~QExplicitlySharedDataPointer (this=<optimized out>, __in_chrg=<optimized out>) at text/qrawfont.cpp:174
#9  QRawFont::~QRawFont (this=<optimized out>, __in_chrg=<optimized out>) at text/qrawfont.cpp:174
#10 0x00007ffff4b55f46 in release_QRawFont (sipCppV=0xa087f0) at sipQtGuiQRawFont.cpp:936
#11 0x00007ffff5208e74 in forgetObject (sw=0x7fffec9bf980) at siplib.c:10199
#12 0x00007ffff5208ea9 in sipSimpleWrapper_dealloc (self=0x7fffec9bf980) at siplib.c:9449
#13 0x00007ffff7ab7b66 in subtype_dealloc (self=0x7fffec9bf980) at Objects/typeobject.c:1014
#14 0x00007ffff7a986f7 in insertdict (mp=0x641000, key=0x7ffff7f7d788, hash=13056039271, value=0x7ffff7da4b30 <_Py_NoneStruct>) at Objects/dictobject.c:530
#15 0x00007ffff7a9abb4 in PyDict_SetItem (op=0x641000, key=0x7ffff7f7d788, value=0x7ffff7da4b30 <_Py_NoneStruct>) at Objects/dictobject.c:775
#16 0x00007ffff7a9e5dc in _PyModule_Clear (m=<optimized out>) at Objects/moduleobject.c:138
#17 0x00007ffff7b0d7bf in PyImport_Cleanup () at Python/import.c:445
#18 0x00007ffff7b1a035 in Py_Finalize () at Python/pythonrun.c:454
#19 0x00007ffff7b2aacc in Py_Main (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:668
#20 0x00007ffff747760d in __libc_start_main (main=0x400970 <main>, argc=3, ubp_av=0x7fffffffda68, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffda58) at libc-start.c:226
#21 0x00000000004008a9 in _start ()


On Fri, Oct 19, 2012 at 07:38:18PM +0530, Kovid Goyal wrote:
> Hi Phil,
> The following snippet causes a segfault:
> python -c "from PyQt4.Qt import *; app = QApplication([]); f = QRawFont.fromFont(QFont('Arial')); print f.familyName();  print 1"
> However, if I explicitly delete the QRawFont first, the segfault goes
> away:
> python -c "from PyQt4.Qt import *; app = QApplication([]); f = QRawFont.fromFont(QFont('Arial')); print f.familyName(); del f;  print 1"
> Seems to be something wrong in the object lifetime/ownership
> semantics for QRawFont.
> This is on linux PyQt4 4.9.4, SIP 4.14, Qt 4.8.3
> I am unable to generate a backtrace at the moment as I am travelling,
> let me know if you need one, and I'll try to generate it ASAP.
> Kovid.
> -- 
> _____________________________________
> Dr. Kovid Goyal 
> http://www.kovidgoyal.net
> http://calibre-ebook.com
> _____________________________________

> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> !DSPAM:3,50815eec47622150364303!


Dr. Kovid Goyal 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20121028/5a1cb81d/attachment.pgp>

More information about the PyQt mailing list