Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Access violation at qsql_oci when executing/preparing QSqlQuery
Forum Updated to NodeBB v4.3 + New Features

Access violation at qsql_oci when executing/preparing QSqlQuery

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 264 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yihua Liu
    wrote on 20 Apr 2025, 18:58 last edited by
    #1

    In SqlTreeModel.cpp, I first successfully connect to an Oracle database db, then I checked db.isValid() is true and db.isOpen() is true. Then, I create a QSqlQuery and prepare/execute it:

    QSqlQuery table_query(db);
    // table_query.exec("SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER=%1"_L1 % db.userName().toUpper());
    // Prepared statement
    if (const bool prepared = table_query.prepare("SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER=':owner'"); not prepared) {
        qWarning() << "Failed to prepare SELECT TABLE_NAME query:" << table_query.lastError();
    }
    table_query.bindValue(":owner", db.userName().toUpper());
    table_query.exec();  // set active if return true
    

    However, the program throws an exception 0xc0000005 encountered at address 0x7ffe0936c683: Access violation reading location 0xffffffffffffffff at table_query.prepare()
    By debugging, the exception occurs at line 1911 delete d->cols in qsql_oci.cpp:

    bool QOCIResult::internal_prepare()
    {
        Q_D(QOCIResult);
        int r = 0;
        QString noStr;
        QSqlResult::prepare(noStr);
    
        delete d->cols;
        ...
    }
    

    Here, the value of d is 0xcdcdcdcdcdcdcdcd, i.e., d is initialized.
    The function call stack is
    SqlTreeModel::refresh()->QSqlQuery::exec()->QOCIResult::reset->QOCIResult::prepare->QOCIResult:internal_prepare
    How to fix this exception?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 21 Apr 2025, 07:00 last edited by
      #4

      Then apply the patch or use Qt6. 8

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Y 1 Reply Last reply 21 Apr 2025, 11:27
      0
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 20 Apr 2025, 19:13 last edited by
        #2

        What Qt version do you use? see https://bugreports.qt.io/browse/QTBUG-136024

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        Y 1 Reply Last reply 21 Apr 2025, 02:06
        0
        • C Christian Ehrlicher
          20 Apr 2025, 19:13

          What Qt version do you use? see https://bugreports.qt.io/browse/QTBUG-136024

          Y Offline
          Y Offline
          Yihua Liu
          wrote on 21 Apr 2025, 02:06 last edited by
          #3

          @Christian-Ehrlicher Yes I'm using Qt 6.9.0 and my case is exactly the same as this bug.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 21 Apr 2025, 07:00 last edited by
            #4

            Then apply the patch or use Qt6. 8

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            Y 1 Reply Last reply 21 Apr 2025, 11:27
            0
            • C Christian Ehrlicher
              21 Apr 2025, 07:00

              Then apply the patch or use Qt6. 8

              Y Offline
              Y Offline
              Yihua Liu
              wrote on 21 Apr 2025, 11:27 last edited by
              #5

              @Christian-Ehrlicher Hello, I applied the patch in my Qt installation directory, rebuilt and re-installed the SQL driver in that directory, and completely rebuilt my app, but the problem still exists

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 21 Apr 2025, 14:38 last edited by
                #6

                Then you most likely did something wrong. Make sure the oci driver is really built and installed. Also post the complete backtrace once you made sure the new driver is used.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                Y 1 Reply Last reply 21 Apr 2025, 17:19
                0
                • C Christian Ehrlicher
                  21 Apr 2025, 14:38

                  Then you most likely did something wrong. Make sure the oci driver is really built and installed. Also post the complete backtrace once you made sure the new driver is used.

                  Y Offline
                  Y Offline
                  Yihua Liu
                  wrote on 21 Apr 2025, 17:19 last edited by
                  #7

                  @Christian-Ehrlicher Thank you. I found that after I add -DCMAKE_BUILD_TYPE=Debug when I build qoci the qsqlocid.dll, etc. are built and installed, then the problem can be fixed

                  1 Reply Last reply
                  0
                  • Y Yihua Liu has marked this topic as solved on 21 Apr 2025, 17:19

                  5/7

                  21 Apr 2025, 11:27

                  • Login

                  • Login or register to search.
                  5 out of 7
                  • First post
                    5/7
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved