Bug report #9678

Python console : crash when printing from signals

Added by Hugo Mercier over 10 years ago. Updated over 7 years ago.

Status:Closed
Priority:High
Assignee:-
Category:PyQGIS Console
Affected QGIS version:2.2.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:not reproducable
Crashes QGIS or corrupts data:Yes Copied to github as #:18244

Description

When using Python's 'print' command from some signals, and when the console has been activated (i.e. print are not redirected to stdout), frequent crashs occur.
Example of code to reproduce (in the console or from a plugin):

def on_render( _ ):
    print "render complete" 

qgis.utils.iface.mapCanvas().renderComplete.connect(on_render)

Then move the map to trigger the renderComplete.

When using the regular stdout (on the Linux console for instance), it works correctly.

I experienced similar crashes with other signals.

Example of stack trace follows. Another involved a SIGSEGV in QScintilla

It happens with 2.3 238350ff4942, but I am pretty sure it already happened with 2.1

#0  0x00007ffff058c425 in __GI_raise (sig=<optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff058fb8b in __GI_abort () at abort.c:91
#2  0x000000000055e4e8 in qgisCrash (signal=-1)
    at /home/hme/src/Quantum-GIS/src/app/main.cpp:302
#3  0x000000000055e6bf in myMessageOutput (type=QtFatalMsg, 
    msg=0x75dfec8 "ASSERT: \\"mJob == 0\\" in file /home/hme/src/Quantum-GIS/src/gui/qgsmapcanvas.cpp, line 760") at /home/hme/src/Quantum-GIS/src/app/main.cpp:355
#4  0x00007ffff30763d0 in qt_message_output(QtMsgType, char const*) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5  0x00007ffff3076838 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#6  0x00007ffff30769c4 in qFatal(char const*, ...) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#7  0x00007ffff3ced85d in QgsMapCanvas::stopRendering (this=0x14646c0)
    at /home/hme/src/Quantum-GIS/src/gui/qgsmapcanvas.cpp:760
#8  0x00007ffff3cec94e in QgsMapCanvas::refreshMap (this=0x14646c0)
    at /home/hme/src/Quantum-GIS/src/gui/qgsmapcanvas.cpp:653
#9  0x00007ffff3d85441 in QgsMapCanvas::qt_static_metacall (_o=0x14646c0, 
    _c=QMetaObject::InvokeMetaMethod, _id=35, _a=0x7fffffffadc0)
    at /home/hme/src/Quantum-GIS/build/src/gui/moc_qgsmapcanvas.cxx:153
#10 0x00007ffff3192f5f in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#11 0x00007ffff319ac1f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#12 0x00007ffff319226c in QObject::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#13 0x00007ffff2524e9c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
---Type <return> to continue, or q <return> to quit---
#14 0x00007ffff252930a in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#15 0x00007ffff44121e8 in QgsApplication::notify (this=0x7fffffffde00, 
    receiver=0x56a9a80, event=0x7fffffffb540)
    at /home/hme/src/Quantum-GIS/src/core/qgsapplication.cpp:232
#16 0x00007ffff317d56e in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#17 0x00007ffff31ae462 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#18 0x00007ffff31ab584 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#19 0x00007fffeee98ab5 in g_main_context_dispatch ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007fffeee98de8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#21 0x00007fffeee98ea4 in g_main_context_iteration ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#22 0x00007ffff31abbf6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#23 0x00007ffff25c9c1e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#24 0x00007ffff318189f in QCoreApplication::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#25 0x00007fffc957ce9d in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#26 0x00007fffc9afdd72 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#27 0x00007fffc9afec38 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#28 0x00007fffc9b54c76 in ?? () from /usr/lib/libpython2.7.so.1.0
#29 0x00007fffc9bce1be in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#30 0x00007fffc9c324e0 in ?? () from /usr/lib/libpython2.7.so.1.0
#31 0x00007fffc9bce1be in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#32 0x00007fffc9bceac7 in PyEval_CallObjectWithKeywords ()
---Type <return> to continue, or q <return> to quit---
   from /usr/lib/libpython2.7.so.1.0
#33 0x00007fffc9bfceb3 in PyFile_WriteObject () from /usr/lib/libpython2.7.so.1.0
#34 0x00007fffc9bded4a in PyFile_WriteString () from /usr/lib/libpython2.7.so.1.0
#35 0x00007fffc9af90d3 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#36 0x00007fffc9afec38 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#37 0x00007fffc9b54c76 in ?? () from /usr/lib/libpython2.7.so.1.0
#38 0x00007fffc9bce1be in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#39 0x00007fffc9c324e0 in ?? () from /usr/lib/libpython2.7.so.1.0
#40 0x00007fffc9bce1be in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#41 0x00007fffc9bceac7 in PyEval_CallObjectWithKeywords ()
   from /usr/lib/libpython#42 0x00007fffc98a6e70 in sip_api_invoke_slot ()
   from /usr/lib/python2.7/dist-packages/sip.so
#43 0x00007fffc95ca7a6 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#44 0x00007fffc95caaf0 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#45 0x00007fffc95caba2 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#46 0x00007ffff3193123 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#47 0x00007ffff3d85763 in QgsMapCanvas::renderComplete (this=0x14646c0, 
    _t1=0x7fffffffc7e0)
    at /home/hme/src/Quantum-GIS/build/src/gui/moc_qgsmapcanvas.cxx:230
#48 0x00007ffff3ced07e in QgsMapCanvas::rendererJobFinished (this=0x14646c0)
    at /home/hme/src/Quantum-GIS/src/gui/qgsmapcanvas.cpp:715
#49 0x00007ffff3d8541f in QgsMapCanvas::qt_static_metacall (_o=0x14646c0, 
    _c=QMetaObject::InvokeMetaMethod, _id=33, _a=0x7fffffffc9e0)
    at /home/hme/src/Quantum-GIS/build/src/gui/moc_qgsmapcanvas.cxx:151
#50 0x00007ffff3192f5f in QMetaObject::activate(QObject*, QMetaObject const*, int, void**)---Type <return> to continue, or q <return> to quit---
 () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#51 0x00007ffff46fdefb in QgsMapRendererJob::finished (this=0x75ff2a0)
    at /home/hme/src/Quantum-GIS/build/src/core/moc_qgsmaprendererjob.cxx:98
#52 0x00007ffff4326cb3 in QgsMapRendererSequentialJob::internalFinished (this=0x75ff2a0)
    at /home/hme/src/Quantum-GIS/src/core/qgsmaprendererjob.cpp:157
#53 0x00007ffff46fdf6f in QgsMapRendererSequentialJob::qt_static_metacall (_o=0x75ff2a0, 
    _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x7fffffffcba0)
    at /home/hme/src/Quantum-GIS/build/src/core/moc_qgsmaprendererjob.cxx:130
#54 0x00007ffff3192f5f in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#55 0x00007ffff46fdefb in QgsMapRendererJob::finished (this=0x75f0460)
    at /home/hme/src/Quantum-GIS/build/src/core/moc_qgsmaprendererjob.cxx:98
#56 0x00007ffff4327eb8 in QgsMapRendererCustomPainterJob::futureFinished (this=0x75f0460)
    at /home/hme/src/Quantum-GIS/src/core/qgsmaprendererjob.cpp:308
#57 0x00007ffff46fe261 in QgsMapRendererCustomPainterJob::qt_static_metacall (
    _o=0x75f0460, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x7fffffffcd60)
    at /home/hme/src/Quantum-GIS/build/src/core/moc_qgsmaprendererjob.cxx:282
#58 0x00007ffff3192f5f in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#59 0x00007ffff3071477 in QFutureWatcherBase::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#60 0x00007ffff2524e9c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
2.7.so.1.0
#61 0x00007ffff252930a in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#62 0x00007ffff44121e8 in QgsApplication::notify (this=0x7fffffffde00, 
    receiver=0x75f05e0, event=0x7fffd4505f10)
---Type <return> to continue, or q <return> to quit---
    at /home/hme/src/Quantum-GIS/src/core/qgsapplication.cpp:232
#63 0x00007ffff317d56e in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#64 0x00007ffff31813f1 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#65 0x00007ffff31aba63 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#66 0x00007fffeee98ab5 in g_main_context_dispatch ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#67 0x00007fffeee98de8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#68 0x00007fffeee98ea4 in g_main_context_iteration ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#69 0x00007ffff31abbf6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#70 0x00007ffff25c9c1e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#71 0x00007ffff317c2bf in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#72 0x00007ffff317c548 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#73 0x00007ffff3181708 in QCoreApplication::exec() ()
   from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#74 0x0000000000561623 in main (argc=1, argv=0x7fffffffe0c8)
    at /home/hme/src/Quantum-GIS/src/app/main.cpp:1020

History

#1 Updated by Hugo Mercier over 10 years ago

  • Affected QGIS version changed from 2.2.0 to master

#2 Updated by Matthias Kuhn over 10 years ago

Did this start with MT-rendering?
Can you try

def on_render( _ ):
    print "render complete" 

qgis.utils.iface.mapCanvas().renderComplete.connect(on_render, Qt.QueuedConnection)

#3 Updated by Hugo Mercier over 10 years ago

I don't think it started with multi-thread rendering, but cannot be 100% sure (I will have to test on previous versions).
No crash observed when using Qt.QueuedConnection

#4 Updated by Salvatore Larosa over 10 years ago

  • Status changed from Open to Feedback

I can't confirm here, opening the python console and pasting your snippets I am not getting the crash after panning the map.

does it also happen by startig qgis without python plugins?

#5 Updated by Hugo Mercier over 10 years ago

I need to trigger the signal a lot of times before it crashes.
But yes, without plugins it still crashes.

I forgot to mention I use a "DEBUG" compilation.
The line involved in the crash is a Q_ASSERT in qgsmapcanvas.cpp:760.

I don't know if this Q_ASSERT is too pessimistic or not.

#6 Updated by Giovanni Manghi about 10 years ago

  • Status changed from Feedback to Open

#7 Updated by Giovanni Manghi over 7 years ago

  • Status changed from Open to Feedback
  • Crashes QGIS or corrupts data changed from No to Yes
  • Affected QGIS version changed from master to 2.2.0
  • Priority changed from Normal to High

Hi Hugo,

what is the status of this (old) ticket/issue? Still an issue on 2.18.4 qgis3/master? Thanks.

Note:
I changed the affected version back to 2.2 because now "master" means qgis3/master.

#8 Updated by Giovanni Manghi over 7 years ago

  • Resolution set to not reproducable
  • Description updated (diff)
  • Status changed from Feedback to Closed

Hugo, closing for lack of feedback, please reopen is still valid! thanks!

Also available in: Atom PDF