Bug report #13194

QgsVectorLayer.uniqueValues crash qgis if index does not exist

Added by Luigi Pirelli over 9 years ago. Updated over 9 years ago.

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

Description

writing a python plugin and checking the values returned by QgsVectorLayer.uniqeValues(index, limit) call, I noticed that if index is out of index range, this crash QGIS!

can be simulated in the python console loading a vector
v=iface.activeLayer()
v.uniqueValues(1000)

without investigation I suppose can be a SIP problems because of lack of return value from the function

this happend with 2.8.3 and master version. I copile my qgis.
The gdb dump below is related this this qgis version. I'm on Ubuntu 14.10

QGIS version 2.8.3-Wien QGIS code revision 1207e38
Compiled against Qt 4.8.6 Running against Qt 4.8.6
Compiled against GDAL/OGR 1.11.2 Running against GDAL/OGR 1.11.2
Compiled against GEOS 3.4.2-CAPI-1.8.2 Running against GEOS 3.4.2-CAPI-1.8.2 r3921
PostgreSQL Client Version 9.4.4 SpatiaLite Version 4.1.1
QWT Version 5.2.3 PROJ.4 Version 480
QScintilla2 Version 2.8.3 This copy of QGIS writes debugging output.

/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QCoreApplication::exec()+0x99)[0x7ffff2a6d8b9]
Program received signal SIGABRT, Aborted.
/mnt/data/PROGRAMMING/QGIS/QGIS-2.8/build/output/bin/qgis(main+0x311e)[0x57cd72]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fffef838ec5]
/mnt/data/PROGRAMMING/QGIS/QGIS-2.8/build/output/bin/qgis[0x579349]
0x00007fffef84de37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) where
#0 0x00007fffef84de37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007fffef84f528 in __GI_abort () at abort.c:89
#2 0x0000000000579be3 in myMessageOutput (type=QtFatalMsg,
msg=0x78f3a98 "ASSERT failure in QgsVectorLayer::uniqueValues(): \\"Unknown source of the field!\\", file /home/ginetto/PROGRAMMING/QGIS/QGIS-2.8/src/core/qgsvectorlayer.cpp, line 3010") at /home/ginetto/PROGRAMMING/QGIS/QGIS-2.8/src/app/main.cpp:369
#3 0x00007ffff29546a1 in qt_message_output(QtMsgType, char const*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#4 0x00007ffff2954b09 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5 0x00007ffff29553f1 in qFatal(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#6 0x00007ffff41564a9 in QgsVectorLayer::uniqueValues (this=0x5c7b100, index=77, uniqueValues=..., limit=-1)
at /home/ginetto/PROGRAMMING/QGIS/QGIS-2.8/src/core/qgsvectorlayer.cpp:3010
#7 0x00007fff70064c0f in meth_QgsVectorLayer_uniqueValues (sipSelf=0x7fff57d65d60, sipArgs=0x7fff61b9fcd0, sipKwds=0x0)
at /home/ginetto/PROGRAMMING/QGIS/QGIS-2.8/build/python/core/sip_corepart2.cpp:148052
#8 0x00007fff71b20b2c in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#9 0x00007fff71b93000 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#10 0x00007fff71b1b319 in PyEval_EvalCode () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#11 0x00007fff71b2111b in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#12 0x00007fff71b93000 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#13 0x00007fff71b20e31 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#14 0x00007fff71b93000 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#15 0x00007fff71b20e31 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#16 0x00007fff71b20f3d in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#17 0x00007fff71b20f3d in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#18 0x00007fff71b93000 in PyEval_EvalCodeEx () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#19 0x00007fff71ae302c in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#20 0x00007fff71aeb8e3 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#21 0x00007fff71b2dcf5 in ?? () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#22 0x00007fff71aeb8e3 in PyObject_Call () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#23 0x00007fff71b92557 in PyEval_CallObjectWithKeywords () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
#24 0x00007fff71757ef4 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#25 0x00007fff709f0d79 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#26 0x00007fff61d0bd86 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/Qsci.so
#27 0x00007ffff1e095af in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#28 0x00007ffff21cd7be in QFrame::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#29 0x00007ffff22508c3 in QAbstractScrollArea::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#30 0x00007ffff1247589 in QsciScintilla::event(QEvent*) () from /usr/lib/libqscintilla2.so.11
#31 0x00007fff61d0c7b7 in ?? () from /usr/lib/python2.7/dist-packages/PyQt4/Qsci.so
#32 0x00007ffff1db57cc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#33 0x00007ffff1dbda26 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
---Type <return> to continue, or q <return> to quit---q

Associated revisions

Revision 71e7aabb
Added by Jürgen Fischer over 9 years ago

vector layer: ignore non-existing fields in min/max/uniqueValues (fixes #13194)

Revision 35028c02
Added by Jürgen Fischer over 9 years ago

vector layer: ignore non-existing fields in min/max/uniqueValues (fixes #13194)

(cherry picked from commit 71e7aabbdec6cc5d542420948d897f7f7fda8303)

Revision c7b1080f
Added by Jürgen Fischer over 9 years ago

vector layer: ignore non-existing fields in min/max/uniqueValues (fixes #13194)

(cherry picked from commit 71e7aabbdec6cc5d542420948d897f7f7fda8303)

History

#1 Updated by Luigi Pirelli over 9 years ago

  • Crashes QGIS or corrupts data changed from No to Yes

#2 Updated by Jürgen Fischer over 9 years ago

  • Status changed from Open to Closed

#3 Updated by Luigi Pirelli over 9 years ago

verified on master... now it works, thank you Jürgen

I tested that a NULL values column return [NULL] and if there are some values return [NULL, <values>]. So correctly an empty list is the only result in case of erroneous index.

Also available in: Atom PDF