Bug report #15047

ASSERT failure in QVector<T>::at: "index out of range" in qgis_attributetabletest (TestQgsAttributeTable)

Added by Sandro Santilli over 8 years ago. Updated almost 8 years ago.

Status:Closed
Priority:Normal
Assignee:Even Rouault
Category:Attribute table
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:22992

Description

As of 8868303dbd4fad26eeb88bc5a18ba3ffe5a0e719 I get an error (among many) in qgis_attributetabletest:

$ output/bin/qgis_attributetabletest
[...]
QDEBUG : TestQgsAttributeTable::testFieldCalculation() src/core/qgscoordinatereferencesystem.cpp: 999: (findMatchingProj) [1ms] entered.
QDEBUG : TestQgsAttributeTable::testFieldCalculation() src/core/qgscoordinatereferencesystem.cpp: 1041: (findMatchingProj) [4ms] -------> MATCH FOUND in srs.db srsid: 3239
QDEBUG : TestQgsAttributeTable::testFieldCalculation() src/core/qgscoordinatereferencesystem.cpp: 653: (createFromProj4) [1ms] globbing search for srsid returned srsid: 3239
QFATAL : TestQgsAttributeTable::testFieldCalculation() ASSERT failure in QVector<T>::at: "index out of range", file /usr/include/qt4/QtCore/qvector.h, line 351
FAIL!  : TestQgsAttributeTable::testFieldCalculation() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 1 passed, 1 failed, 0 skipped
********* Finished testing of TestQgsAttributeTable *********
Aborted (core dumped)

History

#1 Updated by Sandro Santilli over 8 years ago

Backtrace:

==17926== Process terminating with default action of signal 6 (SIGABRT): dumping core
==17926==    at 0xB46CC37: raise (raise.c:56)
==17926==    by 0xB470027: abort (abort.c:89)
==17926==    by 0x4EA6C91: qt_message_output(QtMsgType, char const*) (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.6)
==17926==    by 0x4EA6FF8: ??? (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.6)
==17926==    by 0x4EA7803: qFatal(char const*, ...) (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.6)
==17926==    by 0x7A2D61C: QVector<int>::at(int) const (qvector.h:351)
==17926==    by 0x7CB3B8D: QgsAttributeTableFilterModel::headerData(int, Qt::Orientation, int) const (qgsattributetablefiltermodel.cpp:104)
==17926==    by 0xA941579: QHeaderView::sectionSizeFromContents(int) const (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==17926==    by 0xA936079: QHeaderView::sizeHint() const (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==17926==    by 0xA9621F5: QTableView::updateGeometries() (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==17926==    by 0xA957555: QTableView::columnCountChanged(int, int) (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==17926==    by 0x4FC7879: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.6)

The offending code snippet [ mColumnMapping.at( 0 ) aborts due to mColumnMapping being empty ]:

QVariant QgsAttributeTableFilterModel::headerData( int section, Qt::Orientation orientation, int role ) const
{                                                                               
  if ( orientation ==  Qt::Horizontal )                                         
  {                                                                             
    if ( mColumnMapping.at( section ) == -1 && role == Qt::DisplayRole )        
      return tr( "Actions" );                                                   
    else                                                                        
      return QSortFilterProxyModel::headerData( section, orientation, role );   
  }                                                                             
  else                                                                          
  {                                                                             
    if ( role == Qt::DisplayRole )                                              
      return section + 1;                                                       
    else                                                                        
    {                                                                           
      int sourceSection = mapToSource( index( section, mColumnMapping.at( 0 ) == -1 ? 1 : 0 ) ).row();
      return sourceModel()->headerData( sourceSection, orientation, role );     
    }                                                                           
  }                                                                             
}               

#2 Updated by Even Rouault over 8 years ago

  • Assignee set to Even Rouault

This also cause a crash when displaying the attribute table on a layer with no attribute fields.

#3 Updated by Even Rouault over 8 years ago

  • % Done changed from 0 to 100
  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

Fixed by 1cd7808

#4 Updated by Tudor Bărăscu almost 8 years ago

  • Status changed from Closed to Reopened

Hello,

I just built the 2.18.2 and I get the crash with the same error message:

Fatal: ASSERT failure in QVector<T>::at: "index out of range", file /usr/include/qt4/QtCore/qvector.h, line 351
Stacktrace (piped through c++filt):
/home/web/qgis-stable/bin/./qgis(+0x6ac9)[0x55b79f14fac9]
/home/web/qgis-stable/bin/./qgis(+0x6ddf)[0x55b79f14fddf]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(qt_message_output(QtMsgType, char const*)+0x2f)[0x7fde64691e2f]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x70301)[0x7fde64692301]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(qFatal(char const*, ...)+0xa1)[0x7fde64692c21]
/home/web/qgis-stable/lib/libqgis_gui.so.2.18.2(+0x224bfd)[0x7fde66746bfd]
/home/web/qgis-stable/lib/libqgis_gui.so.2.18.2(QgsAttributeTableFilterModel::headerData(int, Qt::Orientation, int) const+0x57)[0x7fde6687d543]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QHeaderView::sectionSizeFromContents(int) const+0x5d)[0x7fde64047ead]

The project that I'm using works flawlessly under 2.14.10. The crash happens when I open the attribute table of a certain layer.

Thanks for your great work,
Tudor

#5 Updated by Tudor Bărăscu almost 8 years ago

The error only comes up if I open the 2.14 project first time.
If I save it in 2.18.2 it works afterwards.

Sorry for the noise.

#6 Updated by Tudor Bărăscu almost 8 years ago

  • Status changed from Reopened to Closed

Also available in: Atom PDF