Bug report #8061

python bindings for legendInterface().groupLayerRelationship() gives segfault

Added by Etienne Tourigny over 11 years ago. Updated over 11 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Nathan Woodrow
Category:Python plugins
Affected QGIS version:master Regression?:No
Operating System:linux Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:Yes Copied to github as #:16901

Description

I have a python plugin which uses legendInterface().groupLayerRelationship() and when trying to port it to new spiv2 api I get this error.

I can reproduce without the plugin using the python console.

- start qgis with no layers
- open python console
- type 'iface.legendInterface().groups()' - returns an empty list
- type 'iface.legendInterface().groupLayerRelationship()' - returns an empty list
- add a map layer
- type 'iface.legendInterface().groups()' - returns an empty list
- type 'iface.legendInterface().groupLayerRelationship()' - segfault

segfault occurs here
0x00007fffcff70db8 in convertFrom_QList_0600QPair_0100QString_0600QList_0100QString (sipCppV=0x1da83a0, sipTransferObj=0x0) at /data/src/qgis/qgis-master/python/core/conversions.sip:1450
1450 PyObject *t1obj = sipConvertFromNewInstance(new QString(sipCpp->at(i).second.at(j)), sipClass_QString, sipTransferObj);

following is a log and backtrace (output in qgslegend.cpp was added by me)

I have assigned Nathan as he has been leading the sipV2 effort

Debug: src/core/qgsmaprenderer.cpp: 723: (render) Rendering completed in (seconds): 0.004
Debug: src/app/legend/qgsapplegendinterface.cpp: 133: (groupLayerRelationship) returning mLegend->groupLayerRelationship()
Debug: src/app/legend/qgslegend.cpp: 2234: (groupLayerRelationship) returning list with 1 items
Debug: src/app/legend/qgslegend.cpp: 2237: (groupLayerRelationship) k=[] #v=[1]
Debug: src/app/legend/qgslegend.cpp: 2239: (groupLayerRelationship) s=[landsat20130613173433257]

Program received signal SIGSEGV, Segmentation fault.
0x00007fffcff70db8 in convertFrom_QList_0600QPair_0100QString_0600QList_0100QString (sipCppV=0x1da83a0, sipTransferObj=0x0) at /data/src/qgis/qgis-master/python/core/conversions.sip:1450
1450            PyObject *t1obj = sipConvertFromNewInstance(new QString(sipCpp->at(i).second.at(j)), sipClass_QString, sipTransferObj);
(gdb) 
(gdb) bt
#0  0x00007fffcff70db8 in convertFrom_QList_0600QPair_0100QString_0600QList_0100QString (sipCppV=0x1da83a0, sipTransferObj=0x0) at /data/src/qgis/qgis-master/python/core/conversions.sip:1450
#1  0x00007fffd119f2d1 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#2  0x00007fffcf049034 in meth_QgsLegendInterface_groupLayerRelationship (sipSelf=0x26e70e0, sipArgs=0x1568050) at /data/src/qgis/qgis-master/build-debug/python/gui/sipguipart3.cpp:1093
#3  0x00007fffd1402d72 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#4  0x00007fffd1403c38 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#5  0x00007fffd1403d72 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#6  0x00007fffd1401c3a in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#7  0x00007fffd1403c38 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#8  0x00007fffd140182e in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#9  0x00007fffd1403c38 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#10 0x00007fffd140182e in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#11 0x00007fffd1402e1b in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#12 0x00007fffd1402e1b in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#13 0x00007fffd1403c38 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#14 0x00007fffd1459c76 in ?? () from /usr/lib/libpython2.7.so.1.0
#15 0x00007fffd14d31be in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#16 0x00007fffd15374e0 in ?? () from /usr/lib/libpython2.7.so.1.0
#17 0x00007fffd14d31be in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#18 0x00007fffd14d3ac7 in PyEval_CallObjectWithKeywords () from /usr/lib/libpython2.7.so.1.0
#19 0x00007fffd11a2692 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#20 0x00007fffd0550410 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#21 0x00007fffcd5c9572 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/Qsci.so
#22 0x00007ffff2b9c8db in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#23 0x00007ffff2f4bb66 in QFrame::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#24 0x00007ffff2fcb82b in QAbstractScrollArea::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#25 0x00007fffcd15e2e0 in QsciScintilla::event(QEvent*) () from /usr/lib/libqscintilla2.so.8
#26 0x00007fffcd624d6b in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/Qsci.so
#27 0x00007ffff2b4ce9c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#28 0x00007ffff2b51e84 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#29 0x00007ffff4941ffe in QgsApplication::notify (this=0x7fffffffd220, receiver=0x25f1780, event=0x7fffffffbd10) at /data/src/qgis/qgis-master/src/core/qgsapplication.cpp:241
#30 0x00007ffff37a556e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#31 0x00007ffff2bede79 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#32 0x00007ffff2bee2b1 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#33 0x00007ffff2bc9ed9 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#34 0x00007ffff2bf1fa2 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#35 0x00007fffef4b7ab5 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#36 0x00007fffef4b7de8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#37 0x00007fffef4b7ea4 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#38 0x00007ffff37d3bf6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#39 0x00007ffff2bf1c1e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#40 0x00007ffff37a42bf in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#41 0x00007ffff37a4548 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#42 0x00007ffff37a9708 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#43 0x000000000054d408 in main (argc=1, argv=0x7fffffffd4f8) at /data/src/qgis/qgis-master/src/app/main.cpp:997
(gdb)

fix_sip_QString.patch Magnifier (899 Bytes) Salvatore Larosa, 2013-06-13 02:50 PM

Associated revisions

History

#1 Updated by Etienne Tourigny over 11 years ago

  • Subject changed from python bindings for legendInterface().groupLayerRelationship() gives segfault (when no groups present) to python bindings for legendInterface().groupLayerRelationship() gives segfault

this happens if there are groups or not

#2 Updated by Salvatore Larosa over 11 years ago

Mine is just improvisation.

The attached patch should fix the problem !
(but I do not know if it breaks something else :-)))

#3 Updated by Alexander Bruy over 11 years ago

Works fine here with latest master

#4 Updated by Etienne Tourigny over 11 years ago

I am using python 2.7.3-0ubuntu7 and python-sip 4.13.3-2 in Linux Mint 14 (ubuntu quental), latest master.

The patch by Salvatore works for me. I will test further to make sure it doesn't break anything.

Alexandre: does it work for you after applying the patch? Are you using another sip/python version?

iface.legendInterface().groups()
[]
>>> iface.legendInterface().groupLayerRelationship()
[[u'', [u'lines20130614111717895']]]

#5 Updated by Salvatore Larosa over 11 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF