Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66443

Segfault - Sqlite driver for prepared query jumps to conclusion when/with less values than expected.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.11.0 Beta 3
    • 5.10.1, 5.11.0 Beta 2
    • SQL Support
    • None
    • Suse 42.3

      gcc v7.2.1
    • 0dc7d0b5775c76f44ac3ec07c548bcd321aa5981

    Description

      Commit 3e58f2b090661aab7302132cb2da661c8e227bc2 by Andy Shaw seems to have introduced an issue.

      Line 469-470 of qtbase/src/plugins/sqldrivers/sqlite/qsq_sqlite.cpp states:

       

          // In the case of the reuse of a named placeholder
          if (paramCount < values.count()) {

       

      but this condition is also true when the query (mistakenly) contains a non-existent field in the select clause.

      I.e. given the following query

       

      select <existing field>, <non-existing field> from <some table>;
      
      so something like:
      QSqlQuery _query(m_db);
      _query.prepare("select doesnotexist, :test from product p");
      _query.bindValue(":test", "dummy");
      _query.exec();
      • as a regular query will result in a proper query error, clearly showing the problem with the non-existing field
      • as a prepared query will result in a segfault on an assert

      Assert:

       

      ASSERT: "!isEmpty()" in file /home/development/qt-everywhere-src-5.10.1/qtbase/include/QtCore/../../src/corelib/tools/qlist.h, line 345

       

      Backtrace:

      1   raise                                                                                                  0x7ffff585b8c7
      2   abort                                                                                                  0x7ffff585cc9a
      3   qt_message_fatal                                                            qlogging.cpp          1716 0x7ffff69b9b0e
      4   QMessageLogger::fatal                                                       qlogging.cpp          822  0x7ffff69ba6a6
      5   qt_assert                                                                   qglobal.cpp           3126 0x7ffff69b3ec1
      6   QList<int>::first                                                           qlist.h               345  0x7fffe64975b7
      7   QSQLiteResult::exec                                                         qsql_sqlite.cpp       491  0x7fffe64975b7
      8   QSqlQuery::exec                                                             qsqlquery.cpp         1002 0x7ffff6e9f18c
      9   query(QSqlQuery&)                                                                                      0x40680e       
      10  SelectorQa::updateAnswers()                                                                            0x405d78       
      11  SelectorQa::resetAnswers()                                                                             0x40602a       
      12  SelectorQa::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *)                            0x409f1f       
      13  QQmlPropertyData::writeProperty                                             qqmlpropertycache_p.h 320  0x7ffff71a1590
      14  QQmlObjectCreator::setPropertyValue                                         qqmlobjectcreator.cpp 428  0x7ffff7238fab
      15  QQmlObjectCreator::setPropertyBinding                                       qqmlobjectcreator.cpp 1067 0x7ffff723c930
      16  QQmlObjectCreator::setupBindings                                            qqmlobjectcreator.cpp 779  0x7ffff723ed44
      17  QQmlObjectCreator::populateInstance                                         qqmlobjectcreator.cpp 1408 0x7ffff723b8a7
      18  QQmlObjectCreator::createInstance                                           qqmlobjectcreator.cpp 1272 0x7ffff723c77c
      19  QQmlObjectCreator::setPropertyBinding                                       qqmlobjectcreator.cpp 827  0x7ffff723cce8
      20  QQmlObjectCreator::setupBindings                                            qqmlobjectcreator.cpp 779  0x7ffff723ed44

       

       

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            andysh Andy Shaw
            jirauser24743 user-678dd (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes