Bug report #16685

QgsSpatiaLiteProvider::loadFieldsAbstractInterface trying to assign default values to non-existent fields

Added by Juliusz Hoffman over 7 years ago. Updated over 7 years ago.

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

Description

I have encountered a core dump while working with spatialite layers with latest master e052933b1452b5e45715c1a71f62be9d49ffe0d9

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
#1  0x00007ffff30bc37a in __GI_abort () at abort.c:89
#2  0x000055555555d7c1 in qgisCrash (signal=-1) at /home/migraf/nt1/src/QGIS/src/app/main.cpp:329
#3  0x000055555555da6a in myMessageOutput (type=QtFatalMsg, msg=0x555555e45878 "ASSERT failure in QVector<T>::operator[]: \"index out of range\", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h, line 433")
    at /home/migraf/nt1/src/QGIS/src/app/main.cpp:382
#4  0x00007ffff3a7c99d in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff3a7e439 in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007ffff3a79981 in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007ffff565c78b in QVector<QgsFields::Field>::operator[] (this=0x555555c79b68, i=5) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h:433
#8  0x00007ffff565abe4 in QgsFields::at (this=0x555557fb02e8, i=5) at /home/migraf/nt1/src/QGIS/src/core/qgsfields.cpp:137
#9  0x00007fff6175b8b2 in QgsSpatiaLiteProvider::insertDefaultValue (this=0x555557fb0260, fieldIndex=5, defaultVal=...) at /home/migraf/nt1/src/QGIS/src/providers/spatialite/qgsspatialiteprovider.cpp:890
#10 0x00007fff6175a2eb in QgsSpatiaLiteProvider::loadFieldsAbstractInterface (this=0x555557fb0260, lyr=0x555555e6daf0) at /home/migraf/nt1/src/QGIS/src/providers/spatialite/qgsspatialiteprovider.cpp:735
#11 0x00007fff617587a9 in QgsSpatiaLiteProvider::QgsSpatiaLiteProvider (this=0x555557fb0260, uri=...) at /home/migraf/nt1/src/QGIS/src/providers/spatialite/qgsspatialiteprovider.cpp:568
#12 0x00007fff6176eceb in classFactory (uri=0x555556590fe8) at /home/migraf/nt1/src/QGIS/src/providers/spatialite/qgsspatialiteprovider.cpp:5244
#13 0x00007ffff57c3573 in QgsProviderRegistry::createProvider (this=0x555556acb340, providerKey=..., dataSource=...) at /home/migraf/nt1/src/QGIS/src/core/qgsproviderregistry.cpp:411
#14 0x00007ffff5872dfa in QgsVectorLayer::setDataProvider (this=0x555556590fb0, provider=...) at /home/migraf/nt1/src/QGIS/src/core/qgsvectorlayer.cpp:1480
#15 0x00007ffff5872b38 in QgsVectorLayer::setDataSource (this=0x555556590fb0, dataSource=..., baseName=..., provider=..., loadDefaultStyleFlag=false) at /home/migraf/nt1/src/QGIS/src/core/qgsvectorlayer.cpp:1439
#16 0x00007ffff586a9b9 in QgsVectorLayer::QgsVectorLayer (this=0x555556590fb0, vectorLayerPath=..., baseName=..., providerKey=..., loadDefaultStyleFlag=false) at /home/migraf/nt1/src/QGIS/src/core/qgsvectorlayer.cpp:167
#17 0x00007ffff718d19e in QgisApp::addVectorLayer (this=0x555555d08020, vectorLayerPath=..., baseName=..., providerKey=...) at /home/migraf/nt1/src/QGIS/src/app/qgisapp.cpp:9741

It is caused by trying to assign default field values in QgsSpatiaLiteProvider::loadFieldsAbstractInterface to the geometry column, which was skipped while creating fields.
Attached patch fixed this issue for me, but I am in no way familiar with the QGIS codebase so cannot guarantee this is the right approach.

qgis-spatialite-provider-fix.diff Magnifier - Patch (1.21 KB) Juliusz Hoffman, 2017-06-08 11:08 AM

Associated revisions

Revision f677eaf0
Added by Juliusz Hoffman over 7 years ago

consider middle geometry column when retrieving default values (fixes #16685)

History

#1 Updated by Giovanni Manghi over 7 years ago

  • Status changed from Open to Feedback

Please submit the patch as Pull Request on GitHub, chances of being seen and reviewed here in the bug tracker are very low.

#2 Updated by Juliusz Hoffman over 7 years ago

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed

Also available in: Atom PDF