[PyQt] QPainterPath crash

Jeremy Sanders jeremy at jeremysanders.net
Wed Jun 2 15:09:19 BST 2010


Hi - I'm getting a crash with PyQt4 on Fedora 12 on some code which used to 
work. This is using PyQt4-4.7.3 and sip 4.10.2. Here is a backtrace:

#2  0x0000003e9cc6f133 in __libc_message (do_abort=2, fmt=0x3e9cd3e2f0 "*** 
glibc detected *** %s: %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:186
#3  0x0000003e9cc74ac6 in malloc_printerr (action=3, str=0x3e9cd3c4a8 
"free(): invalid pointer", 
    ptr=<value optimized out>) at malloc.c:6267
#4  0x0000003ea5cf8e58 in cleanup (this=0x31073f0, __in_chrg=<value 
optimized out>) at painting/qpainterpath.cpp:83
#5  ~QScopedPointer (this=0x31073f0, __in_chrg=<value optimized out>)
    at ../../src/corelib/tools/qscopedpointer.h:100
#6  QPainterPath::~QPainterPath (this=0x31073f0, __in_chrg=<value optimized 
out>) at painting/qpainterpath.cpp:583
#7  0x00007f2305a22b56 in release_QPainterPath (sipCppV=0x31073f0) at 
sipQtGuiQPainterPath.cpp:2217
#8  0x00007f230605b329 in ?? () from /usr/lib64/python2.6/site-
packages/sip.so
#9  0x0000003eb78a01b2 in subtype_dealloc (self=0x3901a78) at 
Objects/typeobject.c:1018
#10 0x0000003eb78d9a59 in call_function (f=<value optimized out>, 
throwflag=<value optimized out>)
    at Python/ceval.c:3740
#11 PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value optimized 
out>) at Python/ceval.c:2389
#12 0x0000003eb78de515 in PyEval_EvalCodeEx (co=0x2eb1738, globals=<value 
optimized out>, 
    locals=<value optimized out>, args=<value optimized out>, 
argcount=<value optimized out>, 
    kws=<value optimized out>, kwcount=<value optimized out>, defs=<value 
optimized out>, 
    defcount=<value optimized out>, closure=<value optimized out>) at 
Python/ceval.c:2968
#13 0x0000003eb786daaf in function_call (func=0x2eb8938, arg=0x399fa28, 
kw=0x0) at Objects/funcobject.c:524
#14 0x0000003eb7843b33 in PyObject_Call (func=0x2eb8938, arg=<value 
optimized out>, kw=<value optimized out>)
    at Objects/abstract.c:2492
#15 0x0000003eb7858a3f in instancemethod_call (func=0x2eb8938, 
arg=0x399fa28, kw=0x0) at Objects/classobject.c:2579
#16 0x0000003eb7843b33 in PyObject_Call (func=0x39cc410, arg=<value 
optimized out>, kw=<value optimized out>)
    at Objects/abstract.c:2492
#17 0x0000003eb78d6d13 in PyEval_CallObjectWithKeywords (func=0x39cc410, 
arg=0x3321990, kw=<value optimized out>)
    at Python/ceval.c:3575
#18 0x00007f230605d6fb in ?? () from /usr/lib64/python2.6/site-
packages/sip.so
#19 0x00007f23058b6495 in sipVH_QtGui_142 (sipGILState=PyGILState_UNLOCKED, 
sipMethod=0x39cc410, a0=...)
    at sipQtGuicmodule.cpp:9371
#20 0x00007f2305a2923e in sipQPaintEngine::updateState (this=<value 
optimized out>, a0=...)
    at sipQtGuiQPaintEngine.cpp:182

I don't have a small testcase at the moment, but I think it happens inside a 
class derived from QPaintEngine in the updateState method, which looks like 
this:
    def _updateClipPath(self, clippath, clipoperation):
        """Update clip path given state change."""
        if clipoperation == qt4.Qt.NoClip:
            self.clippath = None
        elif clipoperation == qt4.Qt.ReplaceClip:
            self.clippath = clippath
        elif clipoperation == qt4.Qt.IntersectClip:
            self.clippath = self.clippath.intersected(clippath)
        elif clipoperation == qt4.Qt.UniteClip:
            self.clippath = self.clippath.unite(clippath)

    def updateState(self, state):
        """Examine what has changed in state and call apropriate 
function."""
        self.updatedstate = True
        ss = state.state()
        if ss & qt4.QPaintEngine.DirtyPen:
            self.pen = state.pen()
        if ss & qt4.QPaintEngine.DirtyBrush:
            self.brush = state.brush()
        if ss & qt4.QPaintEngine.DirtyClipPath:
            self._updateClipPath(state.clipPath(), state.clipOperation())
        if ss & qt4.QPaintEngine.DirtyClipRegion:
            path = qt4.QPainterPath()
            path.addRegion(state.clipRegion())
            self._updateClipPath(path, state.clipOperation())
        if ss & qt4.QPaintEngine.DirtyTransform:
            self.matrix = state.matrix()

I think it crashes on entering _updateClipPath.

Thanks

Jeremy



-- 
http://www.jeremysanders.net/



More information about the PyQt mailing list