[PyQt] twisted

Wolfgang Rohdewald wolfgang at rohdewald.de
Thu Nov 5 16:36:46 GMT 2009


I am trying to integrate twisted with a qt4reactor.py
taken from http://bazaar.launchpad.net/~ghtdak/qt4reactor/trunk/annotate/head:/qt4reactor.py

and about one in three times my app generates mysterious segfaults.

Using valgrind I found one problem only. Can somebody see what 
is wrong here? This seems to happen after init code from TwistedSocketNotifier
in qt4reactor.py is executed. But I do not know where.

Can you give me some hints how to debug this myself?
Should I try snapshots of sip and/or pyqt4?

I have:
python-qt4 4.6-1
libqt4 4.5.3really4.5.2-0ubuntu1, whatever the ubuntu guys mean with that.
python-sip4 4.9.1-snapshot-20091015-0ubuntu1


==23718== Invalid read of size 1                                                                                                  
==23718==    at 0x472BF4A: ??? (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so)                                                   
==23718==    by 0x472C004: ??? (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so)
==23718==    by 0x4910262: QMetaObject::activate(QObject*, int, int, void**) (qobject.cpp:3113)
==23718==    by 0x4910EC1: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (qobject.cpp:3187)
==23718==    by 0x494A502: QSocketNotifier::activated(int) (moc_qsocketnotifier.cpp:83)
==23718==    by 0x4914C86: QSocketNotifier::event(QEvent*) (qsocketnotifier.cpp:316)
==23718==    by 0x46B649F: ??? (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so)
==23718==    by 0x5394F53: QApplicationPrivate::notify_helper(QObject*, QEvent*) (qapplication.cpp:4056)
==23718==    by 0x539C67B: QApplication::notify(QObject*, QEvent*) (qapplication.cpp:3603)
==23718==    by 0x74D0BF9: KApplication::notify(QObject*, QEvent*) (kapplication.cpp:302)
==23718==    by 0x70D1F62: sipKApplication::notify(QObject*, QEvent*) (in /usr/lib/pyshared/python2.6/PyKDE4/kdeui.so)
==23718==    by 0x48FA6CA: QCoreApplication::notifyInternal(QObject*, QEvent*) (qcoreapplication.cpp:610)
==23718==  Address 0x8c921d4 is 12 bytes inside a block of size 64 free'd
==23718==    at 0x402454D: operator delete(void*) (vg_replace_malloc.c:346)
==23718==    by 0x472D95C: ??? (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so)
==23718==    by 0x47317CD: ??? (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so)
==23718==    by 0x47AF4C5: sip_api_disconnect_rx (in /usr/lib/pyshared/python2.6/sip.so)
==23718==    by 0x470D314: ??? (in /usr/lib/pyshared/python2.6/PyQt4/QtCore.so)
==23718==    by 0x80DC0CF: PyEval_EvalFrameEx (ceval.c:3706)
==23718==    by 0x80DD383: PyEval_EvalFrameEx (ceval.c:3792)
==23718==    by 0x80DD383: PyEval_EvalFrameEx (ceval.c:3792)
==23718==    by 0x80DD383: PyEval_EvalFrameEx (ceval.c:3792)
==23718==    by 0x80DD383: PyEval_EvalFrameEx (ceval.c:3792)
==23718==    by 0x80DDDF1: PyEval_EvalCodeEx (ceval.c:2968)
==23718==    by 0x816022E: function_call (funcobject.c:524)
==23718==

Application: kmj (kmj.py), signal: Segmentation fault
[Current thread is 1 (Thread 0xb77b76c0 (LWP 24663))]

Thread 2 (Thread 0xb6105b70 (LWP 24665)):
#0  0x00e57422 in __kernel_vsyscall ()
#1  0x00b41f75 in sem_wait@@GLIBC_2.1 () at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/sem_wait.S:80
#2  0x081047a8 in PyThread_acquire_lock (lock=0x98c0628, waitflag=1) at ../Python/thread_pthread.h:349
#3  0x0810794c in lock_PyThread_acquire_lock (self=0x919c340, args=0xb777702c) at ../Modules/threadmodule.c:46
#4  0x080dc0d0 in call_function (f=0x98c04a4, throwflag=0) at ../Python/ceval.c:3706
#5  PyEval_EvalFrameEx (f=0x98c04a4, throwflag=0) at ../Python/ceval.c:2389
#6  0x080dddf2 in PyEval_EvalCodeEx (co=0x8df6140, globals=0x8de2934, locals=0x0, args=0x98bf78c, argcount=1, 
kws=0x98bf790, kwcount=0, defs=0x8dfaef8, defcount=1, closure=0x0)
    at ../Python/ceval.c:2968
#7  0x080dc1b4 in fast_function (f=0x98bf63c, throwflag=0) at ../Python/ceval.c:3802
#8  call_function (f=0x98bf63c, throwflag=0) at ../Python/ceval.c:3727
#9  PyEval_EvalFrameEx (f=0x98bf63c, throwflag=0) at ../Python/ceval.c:2389
#10 0x080dddf2 in PyEval_EvalCodeEx (co=0x8ed75c0, globals=0x8ed22d4, locals=0x0, args=0x98bf5fc, argcount=1, 
kws=0x98bf600, kwcount=0, defs=0x8ed6b78, defcount=2, closure=0x0)
    at ../Python/ceval.c:2968
#11 0x080dc1b4 in fast_function (f=0x98bf49c, throwflag=0) at ../Python/ceval.c:3802
#12 call_function (f=0x98bf49c, throwflag=0) at ../Python/ceval.c:3727
#13 PyEval_EvalFrameEx (f=0x98bf49c, throwflag=0) at ../Python/ceval.c:2389
#14 0x080dddf2 in PyEval_EvalCodeEx (co=0x91ae380, globals=0x98dc934, locals=0x0, args=0x98d4e78, argcount=1, 
kws=0x92af0b8, kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#15 0x0816022f in function_call (func=0x98db6f4, arg=0x98d4e6c, kw=0x98e013c) at ../Objects/funcobject.c:524
#16 0x0806120a in PyObject_Call (func=0x98db6f4, arg=0x98d4e6c, kw=0x98e013c) at ../Objects/abstract.c:2492
#17 0x080daf19 in ext_do_call (f=0x98bf334, throwflag=0) at ../Python/ceval.c:4019
#18 PyEval_EvalFrameEx (f=0x98bf334, throwflag=0) at ../Python/ceval.c:2429
#19 0x080dd384 in fast_function (f=0x98bf18c, throwflag=0) at ../Python/ceval.c:3792
#20 call_function (f=0x98bf18c, throwflag=0) at ../Python/ceval.c:3727
#21 PyEval_EvalFrameEx (f=0x98bf18c, throwflag=0) at ../Python/ceval.c:2389
#22 0x080dd384 in fast_function (f=0x98bf02c, throwflag=0) at ../Python/ceval.c:3792
#23 call_function (f=0x98bf02c, throwflag=0) at ../Python/ceval.c:3727
#24 PyEval_EvalFrameEx (f=0x98bf02c, throwflag=0) at ../Python/ceval.c:2389
#25 0x080dddf2 in PyEval_EvalCodeEx (co=0x8df6a88, globals=0x8de2934, locals=0x0, args=0x98d4df8, argcount=1, kws=0x0, 
kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#26 0x0816014c in function_call (func=0x8e01304, arg=0x98d4dec, kw=0x0) at ../Objects/funcobject.c:524
#27 0x0806120a in PyObject_Call (func=0x8e01304, arg=0x98d4dec, kw=0x0) at ../Objects/abstract.c:2492
#28 0x080684ac in instancemethod_call (func=0x987dc0c, arg=0x98d4dec, kw=0x0) at ../Objects/classobject.c:2579
#29 0x0806120a in PyObject_Call (func=0x987dc0c, arg=0xb777702c, kw=0x0) at ../Objects/abstract.c:2492
#30 0x080d6ef2 in PyEval_CallObjectWithKeywords (func=0x987dc0c, arg=0xb777702c, kw=0x0) at ../Python/ceval.c:3575
#31 0x08107d88 in t_bootstrap (boot_raw=0x98bb778) at ../Modules/threadmodule.c:425
#32 0x00b3b80e in start_thread (arg=0xb6105b70) at pthread_create.c:300
#33 0x001dc7ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

Thread 1 (Thread 0xb77b76c0 (LWP 24663)):
[KCrash Handler]
#6  0x00cb8f58 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#7  0x00cb9005 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#8  0x003ca263 in QMetaObject::activate (sender=0x97cfc98, from_signal_index=4, to_signal_index=4, argv=0xbfdca968) at 
kernel/qobject.cpp:3113
#9  0x003caec2 in QMetaObject::activate (sender=0x97cfc98, m=0x4a58b0, local_signal_index=0, argv=0xbfdca968) at 
kernel/qobject.cpp:3187
#10 0x00404503 in QSocketNotifier::activated (this=0x97cfc98, _t1=13) at .moc/release-shared/moc_qsocketnotifier.cpp:83
#11 0x003cec87 in QSocketNotifier::event (this=0x97cfc98, e=0xbfdcadb4) at kernel/qsocketnotifier.cpp:316
#12 0x00c434a0 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#13 0x01768f54 in QApplicationPrivate::notify_helper (this=0x8c1f2c8, receiver=0x97cfc98, e=0xbfdcadb4) at 
kernel/qapplication.cpp:4056
#14 0x0177067c in QApplication::notify (this=0x8c1f228, receiver=0x97cfc98, e=0xbfdcadb4) at kernel/qapplication.cpp:3603
#15 0x02516bfa in KApplication::notify (this=0x8c1f228, receiver=0x97cfc98, event=0xbfdcadb4) at 
../../kdeui/kernel/kapplication.cpp:302
#16 0x03a87f63 in sipKApplication::notify(QObject*, QEvent*) () from /usr/lib/pymodules/python2.6/PyKDE4/kdeui.so
#17 0x003b46cb in QCoreApplication::notifyInternal (this=0x8c1f228, receiver=0x97cfc98, event=0xbfdcadb4) at 
kernel/qcoreapplication.cpp:610
#18 0x003df2ca in QCoreApplication::sendEvent (source=0x8c22008) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:213
#19 socketNotifierSourceDispatch (source=0x8c22008) at kernel/qeventdispatcher_glib.cpp:110
#20 0x005f0e78 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#21 0x005f4720 in ?? () from /lib/libglib-2.0.so.0
#22 0x005f4853 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#23 0x003df02c in QEventDispatcherGlib::processEvents (this=0x8b5fa50, flags=...) at kernel/qeventdispatcher_glib.cpp:327
#24 0x01809be5 in QGuiEventDispatcherGlib::processEvents (this=0x8b5fa50, flags=...) at 
kernel/qguieventdispatcher_glib.cpp:202
#25 0x003b56e1 in QCoreApplication::processEvents (flags=) at kernel/qcoreapplication.cpp:803
#26 0x00c8dfe0 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#27 0x080dc0d0 in call_function (f=0x945673c, throwflag=0) at ../Python/ceval.c:3706
#28 PyEval_EvalFrameEx (f=0x945673c, throwflag=0) at ../Python/ceval.c:2389
#29 0x080dddf2 in PyEval_EvalCodeEx (co=0x8b91a88, globals=0x8bb179c, locals=0x0, args=0x8a3a5f8, argcount=1, kws=0x0, 
kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#30 0x0816014c in function_call (func=0x8f5e17c, arg=0x8a3a5ec, kw=0x0) at ../Objects/funcobject.c:524
#31 0x0806120a in PyObject_Call (func=0x8f5e17c, arg=0x8a3a5ec, kw=0x0) at ../Objects/abstract.c:2492
#32 0x080684ac in instancemethod_call (func=0x8eef784, arg=0x8a3a5ec, kw=0x0) at ../Objects/classobject.c:2579
#33 0x0806120a in PyObject_Call (func=0x8eef784, arg=0xb777702c, kw=0x0) at ../Objects/abstract.c:2492
#34 0x080d6ef2 in PyEval_CallObjectWithKeywords (func=0x8eef784, arg=0xb777702c, kw=0x0) at ../Python/ceval.c:3575
#35 0x00ae4717 in sip_api_invoke_slot () from /usr/lib/pymodules/python2.6/sip.so
#36 0x00cb8e53 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#37 0x00cb8f4a in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#38 0x00cb9005 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#39 0x003ca263 in QMetaObject::activate (sender=0x8f38200, from_signal_index=4, to_signal_index=4, argv=0x0) at 
kernel/qobject.cpp:3113
#40 0x003caec2 in QMetaObject::activate (sender=0x8f38200, m=0x4a5904, local_signal_index=0, argv=0x0) at 
kernel/qobject.cpp:3187
#41 0x00404667 in QTimer::timeout (this=0x8f38200) at .moc/release-shared/moc_qtimer.cpp:128
#42 0x003cf9ae in QTimer::timerEvent (this=0x8f38200, e=0xbfdcbc10) at kernel/qtimer.cpp:261
#43 0x00c150a0 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#44 0x003c43bf in QObject::event (this=0x8f38200, e=0xbfdcbc10) at kernel/qobject.cpp:1075
#45 0x00c15036 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#46 0x01768f54 in QApplicationPrivate::notify_helper (this=0x8c1f2c8, receiver=0x8f38200, e=0xbfdcbc10) at 
kernel/qapplication.cpp:4056
#47 0x0177067c in QApplication::notify (this=0x8c1f228, receiver=0x8f38200, e=0xbfdcbc10) at kernel/qapplication.cpp:3603
#48 0x02516bfa in KApplication::notify (this=0x8c1f228, receiver=0x8f38200, event=0xbfdcbc10) at 
../../kdeui/kernel/kapplication.cpp:302
#49 0x03a87f63 in sipKApplication::notify(QObject*, QEvent*) () from /usr/lib/pymodules/python2.6/PyKDE4/kdeui.so
#50 0x003b46cb in QCoreApplication::notifyInternal (this=0x8c1f228, receiver=0x8f38200, event=0xbfdcbc10) at 
kernel/qcoreapplication.cpp:610
#51 0x003e17ce in QCoreApplication::sendEvent (this=0x8c2207c) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:213
#52 QTimerInfoList::activateTimers (this=0x8c2207c) at kernel/qeventdispatcher_unix.cpp:572
#53 0x003df0e0 in timerSourceDispatch (source=0x8c22048) at kernel/qeventdispatcher_glib.cpp:165
#54 0x005f0e78 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#55 0x005f4720 in ?? () from /lib/libglib-2.0.so.0
#56 0x005f4853 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#57 0x003df02c in QEventDispatcherGlib::processEvents (this=0x8b5fa50, flags=...) at kernel/qeventdispatcher_glib.cpp:327
#58 0x01809be5 in QGuiEventDispatcherGlib::processEvents (this=0x8b5fa50, flags=...) at 
kernel/qguieventdispatcher_glib.cpp:202
#59 0x003b2c79 in QEventLoop::processEvents (this=0xbfdcbed4, flags=) at kernel/qeventloop.cpp:149
#60 0x003b30ca in QEventLoop::exec (this=0xbfdcbed4, flags=...) at kernel/qeventloop.cpp:201
#61 0x003b553f in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
#62 0x01768dd7 in QApplication::exec () at kernel/qapplication.cpp:3525
#63 0x01430102 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtGui.so
#64 0x080dc0d0 in call_function (f=0x90a03a4, throwflag=0) at ../Python/ceval.c:3706
#65 PyEval_EvalFrameEx (f=0x90a03a4, throwflag=0) at ../Python/ceval.c:2389
#66 0x080dd384 in fast_function (f=0x8a7e504, throwflag=0) at ../Python/ceval.c:3792
#67 call_function (f=0x8a7e504, throwflag=0) at ../Python/ceval.c:3727
#68 PyEval_EvalFrameEx (f=0x8a7e504, throwflag=0) at ../Python/ceval.c:2389
#69 0x080dddf2 in PyEval_EvalCodeEx (co=0x8a392f0, globals=0xb77a91c4, locals=0xb77a91c4, args=0x0, argcount=0, kws=0x0, 
kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#70 0x080ddef7 in PyEval_EvalCode (co=0x8a392f0, globals=0xb77a91c4, locals=0xb77a91c4) at ../Python/ceval.c:522
#71 0x080faa1f in run_mod (fp=0x8a7e090, filename=0xb7629e54 "kmj.py", start=257, globals=0xb77a91c4, locals=0xb77a91c4, 
closeit=1, flags=0x0) at ../Python/pythonrun.c:1335
#72 PyRun_FileExFlags (fp=0x8a7e090, filename=0xb7629e54 "kmj.py", start=257, globals=0xb77a91c4, locals=0xb77a91c4, 
closeit=1, flags=0x0) at ../Python/pythonrun.c:1321
#73 0x080d5f89 in builtin_execfile (self=0x0, args=0xb7629eac) at ../Python/bltinmodule.c:790
#74 0x080dc0d0 in call_function (f=0x8a7db1c, throwflag=0) at ../Python/ceval.c:3706
#75 PyEval_EvalFrameEx (f=0x8a7db1c, throwflag=0) at ../Python/ceval.c:2389
#76 0x080dddf2 in PyEval_EvalCodeEx (co=0x8a391d0, globals=0xb77a91c4, locals=0xb77a91c4, args=0x0, argcount=0, kws=0x0, 
kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#77 0x080ddef7 in PyEval_EvalCode (co=0x8a391d0, globals=0xb77a91c4, locals=0xb77a91c4) at ../Python/ceval.c:522
#78 0x080fb2d9 in run_mod (str=0xb7626b74 "execfile( \"kmj.py\")\n", start=257, globals=0xb77a91c4, locals=0xb77a91c4, 
flags=0x0) at ../Python/pythonrun.c:1335
#79 PyRun_StringFlags (str=0xb7626b74 "execfile( \"kmj.py\")\n", start=257, globals=0xb77a91c4, locals=0xb77a91c4, 
flags=0x0) at ../Python/pythonrun.c:1298
#80 0x080dccbf in exec_statement (f=0x8a7b97c, throwflag=0) at ../Python/ceval.c:4437
#81 PyEval_EvalFrameEx (f=0x8a7b97c, throwflag=0) at ../Python/ceval.c:1717
#82 0x080dddf2 in PyEval_EvalCodeEx (co=0xb75ffda0, globals=0xb7772604, locals=0x0, args=0x8a7b954, argcount=2, 
kws=0x8a7b95c, kwcount=0, defs=0xb75ef5b8, defcount=2, closure=0x0)
    at ../Python/ceval.c:2968
#83 0x080dc1b4 in fast_function (f=0x8a7b80c, throwflag=0) at ../Python/ceval.c:3802
#84 call_function (f=0x8a7b80c, throwflag=0) at ../Python/ceval.c:3727
#85 PyEval_EvalFrameEx (f=0x8a7b80c, throwflag=0) at ../Python/ceval.c:2389
#86 0x080dd384 in fast_function (f=0x8a28164, throwflag=0) at ../Python/ceval.c:3792
#87 call_function (f=0x8a28164, throwflag=0) at ../Python/ceval.c:3727
#88 PyEval_EvalFrameEx (f=0x8a28164, throwflag=0) at ../Python/ceval.c:2389
#89 0x080dd384 in fast_function (f=0x89da014, throwflag=0) at ../Python/ceval.c:3792
#90 call_function (f=0x89da014, throwflag=0) at ../Python/ceval.c:3727
#91 PyEval_EvalFrameEx (f=0x89da014, throwflag=0) at ../Python/ceval.c:2389
#92 0x080dddf2 in PyEval_EvalCodeEx (co=0xb75f1650, globals=0xb77a91c4, locals=0xb77a91c4, args=0x0, argcount=0, kws=0x0, 
kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#93 0x080ddef7 in PyEval_EvalCode (co=0xb75f1650, globals=0xb77a91c4, locals=0xb77a91c4) at ../Python/ceval.c:522
#94 0x080faa1f in run_mod (fp=0x898baf8, filename=0xbfdce1c6 "/usr/bin/pdb", start=257, globals=0xb77a91c4, 
locals=0xb77a91c4, closeit=1, flags=0xbfdccb2c) at ../Python/pythonrun.c:1335
#95 PyRun_FileExFlags (fp=0x898baf8, filename=0xbfdce1c6 "/usr/bin/pdb", start=257, globals=0xb77a91c4, 
locals=0xb77a91c4, closeit=1, flags=0xbfdccb2c) at ../Python/pythonrun.c:1321
#96 0x080fac12 in PyRun_SimpleFileExFlags (fp=0x898baf8, filename=0xbfdce1c6 "/usr/bin/pdb", closeit=1, flags=0xbfdccb2c) 
at ../Python/pythonrun.c:931
#97 0x0805c8d8 in Py_Main (argc=3, argv=0xbfdccc14) at ../Modules/main.c:599
#98 0x0805baeb in main (argc=3, argv=0xbfdccc14) at ../Modules/python.c:23

-- 
Wolfgang


More information about the PyQt mailing list