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

Invalid read memory(valgrind) QSqlDatabase

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.15.2
    • SQL Support
    • None
    • Ubuntu(linux) bash environment.
    • Linux/Other display system

    Description

      • The code below generates an invalid read memory with valgrind. When we remove checking(QSqlDatabse::contains), there is no more error.
      • The same issue, when we check DATABASE_CONNECTION_NAME with QsqlDatabase::database(DATABASE_CONNECTION_NAME).isvalid()
      • when we use valgrind embedded in QtCreator, there is no problem, but when we execute valgrind in console the issue appear.
      // espace réservé du code
      if(!QSqlDatabase::contains(DATABASE_CONNECTION_NAME))
      {
              QSqlDatabase db(QSqlDatabase::addDatabase(DATABASE_SQL_DRIVER_NAME, DATABASE_CONNECTION_NAME));
      
              db.setHostName(DEFAULT_IP);
              db.setPort(DATABASE_PORT);
              db.setUserName(DATABASE_USER_NAME);
              db.setPassword(DATABASE_PASSWORD);
              db.setDatabaseName(DATABASE_NAME);
      }
      

      Below a part of printed valgrind error

       

      A part of Printed valgrind invalid read memory
      Block was alloc'd at
      ==81191== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==81191== by 0x82BB967: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x82B9212: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x82B92B3: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x82B9334: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x82B9744: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x8269D60: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x8269FBB: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x826A8ED: ??? (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x8254FE9: mysql_server_init (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.21.2.28)
      ==81191== by 0x529113A: qLibraryInit() (qsql_mysql.cpp:1100)
      ==81191== by 0x5292DAE: QMYSQLDriver::QMYSQLDriver(QObject*) (qsql_mysql.cpp:1130)
      ==81191== by 0x5299294: QMYSQLDriverPlugin::create(QString const&) (main.cpp:67)
      ==81191== by 0x48637B1: qLoadPlugin<QSqlDriver, QSqlDriverPlugin> (qfactoryloader_p.h:108)
      ==81191== by 0x48637B1: QSqlDatabasePrivate::init(QString const&) (qsqldatabase.cpp:699)
      ==81191== by 0x4863BA0: QSqlDatabase::addDatabase(QString const&, QString const&) (qsqldatabase.cpp:472)
      ==81191== by 0x401294: main (main.cpp:18)

      Attachments

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

        Activity

          People

            chehrlic Christian Ehrlicher
            chrisebongue chrisebongue
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes