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. QMYSQL SIGSEGV
Forum Updated to NodeBB v4.3 + New Features

QMYSQL SIGSEGV

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 3 Posters 5.0k Views 2 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Can you show the stack trace ?

    By the way, 5.9.4 just got released, it's worth checking if it behaves better.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ckvsoft
      wrote on last edited by
      #5

      Hi
      Hope this helps ...

      signal 11 (Speicherzugriffsfehler), address is 0x1b0 from 0x7fffcff1e5ea
      [bt]: (1) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x375ea) [0x7fffcff1e5ea]
      [bt]: (2) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x375ea) [0x7fffcff1e5ea]
      [bt]: (3) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x3865c) [0x7fffcff1f65c]
      [bt]: (4) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x2cbdc) [0x7fffcff13bdc]
      [bt]: (5) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x27516) [0x7fffcff0e516]
      [bt]: (6) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(mysql_stmt_prepare+0x96) [0x7fffcff0e8a6]
      [bt]: (7) /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so(+0xc70c) [0x7fffd050370c]
      [bt]: (8) /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5(_ZN10QSqlResult11savePrepareERK7QString+0x200) [0x7ffff64260d0]
      [bt]: (9) /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5(_ZN9QSqlQuery7prepareERK7QString+0x208) [0x7ffff6417008]
      [bt]: (10) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN8Database17getCashRegisterIdEv+0x80) [0x7ffff791f2aa]
      [bt]: (11) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN14VersionChecker10getVersionEv+0x25e) [0x7ffff7992e6a]
      [bt]: (12) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN9QtPrivate11FunctorCallINS_11IndexesListIJEEENS_4ListIJEEEvM14VersionCheckerFvvEE4callES7_PS5_PPv+0x7a) [0x7ffff7993e80]
      [bt]: (13) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN9QtPrivate15FunctionPointerIM14VersionCheckerFvvEE4callINS_4ListIJEEEvEEvS3_PS1_PPv+0x42) [0x7ffff7993e03]
      [bt]: (14) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN9QtPrivate11QSlotObjectIM14VersionCheckerFvvENS_4ListIJEEEvE4implEiPNS_15QSlotObjectBaseEP7QObjectPPvPb+0x6c) [0x7ffff7993d6d]
      [bt]: (15) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x97f) [0x7ffff5f729ff]
      [bt]: (16) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN6QTimer7timeoutENS_14QPrivateSignalE+0x37) [0x7ffff5f7f3b7]
      [bt]: (17) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN6QTimer10timerEventEP11QTimerEvent+0x28) [0x7ffff5f7f718]
      [bt]: (18) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN7QObject5eventEP6QEvent+0x9b) [0x7ffff5f7340b]
      [bt]: (19) /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x9c) [0x7ffff6f0746c]
      [bt]: (20) /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x2a4) [0x7ffff6f0ed34]
      [bt]: (21) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent+0x118) [0x7ffff5f43de8]
      [bt]: (22) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN14QTimerInfoList14activateTimersEv+0x40e) [0x7ffff5f9b91e]
      [bt]: (23) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0x2e20e1) [0x7ffff5f9c0e1]
      [bt]: (24) /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2e7) [0x7ffff2a69fb7]
      [bt]: (25) /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4b1f0) [0x7ffff2a6a1f0]
      [bt]: (26) /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7ffff2a6a27c]
      [bt]: (27) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x5f) [0x7ffff5f9c47f]
      [bt]: (28) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0x13a) [0x7ffff5f41e3a]
      [bt]: (29) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN7QThread4execEv+0x6a) [0x7ffff5d613ca]
      [bt]: (30) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0xac29d) [0x7ffff5d6629d]
      [bt]: (31) /lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc) [0x7ffff5aa27fc]
      [bt]: (32) /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7ffff5232b5f]
      

      lg Chris

      JonBJ 1 Reply Last reply
      0
      • C ckvsoft

        Hi
        Hope this helps ...

        signal 11 (Speicherzugriffsfehler), address is 0x1b0 from 0x7fffcff1e5ea
        [bt]: (1) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x375ea) [0x7fffcff1e5ea]
        [bt]: (2) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x375ea) [0x7fffcff1e5ea]
        [bt]: (3) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x3865c) [0x7fffcff1f65c]
        [bt]: (4) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x2cbdc) [0x7fffcff13bdc]
        [bt]: (5) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(+0x27516) [0x7fffcff0e516]
        [bt]: (6) /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20(mysql_stmt_prepare+0x96) [0x7fffcff0e8a6]
        [bt]: (7) /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlmysql.so(+0xc70c) [0x7fffd050370c]
        [bt]: (8) /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5(_ZN10QSqlResult11savePrepareERK7QString+0x200) [0x7ffff64260d0]
        [bt]: (9) /usr/lib/x86_64-linux-gnu/libQt5Sql.so.5(_ZN9QSqlQuery7prepareERK7QString+0x208) [0x7ffff6417008]
        [bt]: (10) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN8Database17getCashRegisterIdEv+0x80) [0x7ffff791f2aa]
        [bt]: (11) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN14VersionChecker10getVersionEv+0x25e) [0x7ffff7992e6a]
        [bt]: (12) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN9QtPrivate11FunctorCallINS_11IndexesListIJEEENS_4ListIJEEEvM14VersionCheckerFvvEE4callES7_PS5_PPv+0x7a) [0x7ffff7993e80]
        [bt]: (13) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN9QtPrivate15FunctionPointerIM14VersionCheckerFvvEE4callINS_4ListIJEEEvEEvS3_PS1_PPv+0x42) [0x7ffff7993e03]
        [bt]: (14) /home/chris/Dokumente/projects/qt/build-QRK-Desktop-Debug/qrkcore/libQrkCore.so.1(_ZN9QtPrivate11QSlotObjectIM14VersionCheckerFvvENS_4ListIJEEEvE4implEiPNS_15QSlotObjectBaseEP7QObjectPPvPb+0x6c) [0x7ffff7993d6d]
        [bt]: (15) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x97f) [0x7ffff5f729ff]
        [bt]: (16) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN6QTimer7timeoutENS_14QPrivateSignalE+0x37) [0x7ffff5f7f3b7]
        [bt]: (17) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN6QTimer10timerEventEP11QTimerEvent+0x28) [0x7ffff5f7f718]
        [bt]: (18) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN7QObject5eventEP6QEvent+0x9b) [0x7ffff5f7340b]
        [bt]: (19) /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x9c) [0x7ffff6f0746c]
        [bt]: (20) /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x2a4) [0x7ffff6f0ed34]
        [bt]: (21) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent+0x118) [0x7ffff5f43de8]
        [bt]: (22) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN14QTimerInfoList14activateTimersEv+0x40e) [0x7ffff5f9b91e]
        [bt]: (23) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0x2e20e1) [0x7ffff5f9c0e1]
        [bt]: (24) /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2e7) [0x7ffff2a69fb7]
        [bt]: (25) /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4b1f0) [0x7ffff2a6a1f0]
        [bt]: (26) /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7ffff2a6a27c]
        [bt]: (27) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x5f) [0x7ffff5f9c47f]
        [bt]: (28) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0x13a) [0x7ffff5f41e3a]
        [bt]: (29) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN7QThread4execEv+0x6a) [0x7ffff5d613ca]
        [bt]: (30) /usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0xac29d) [0x7ffff5d6629d]
        [bt]: (31) /lib/x86_64-linux-gnu/libpthread.so.0(+0x77fc) [0x7ffff5aa27fc]
        [bt]: (32) /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7ffff5232b5f]
        

        lg Chris

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #6

        @ckvsoft
        At what precise point from your code does this SEGV occur? It looks like it's just in your query.prepare() statement, without even getting as far as the execute, is that what you find stepping through?

        Also, why do you think you're having to specify all those timeout/reconnect options, else you say it loses connection. It shouldn't be losing connection anyway. Unless that's an artefact of an underlying problem which sometimes SEGVs and sometimes doesn't...

        1 Reply Last reply
        1
        • C Offline
          C Offline
          ckvsoft
          wrote on last edited by ckvsoft
          #7

          @JonB
          This was a test while without these Options i got a "Lost connection to MySQL server during query" without SEGV but the Query was not made. The Server is running normaly without troubles Its a TCP connection while not on the same machine. I test an other Server with do the same. Tomorow i will test a localhost machine.

          Its not allways the same query and not allways the prepare. Sometimes it is by "QSqlQuery query(dbc)" and somtime by the exec.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            What is that qrkcore library you are using ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            C 1 Reply Last reply
            0
            • SGaistS SGaist

              What is that qrkcore library you are using ?

              C Offline
              C Offline
              ckvsoft
              wrote on last edited by
              #9

              @SGaist
              This is a Part of my Application . Why?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #10

                Well... To know whether it's an external library you are using or something you are implementing.

                Do you have the same crash if you implement just a minimal application that connects to the database and does the queries ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  ckvsoft
                  wrote on last edited by
                  #11

                  @SGaist
                  I will try this at weekend. Also i will test if MySQL and MariaDB has the same. The queries where made from the library. Thx for the time

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    ckvsoft
                    wrote on last edited by ckvsoft
                    #12

                    Hi
                    I connect to a localhost mysql server and it seems to work. When i has running in the background some sql queries and i do at the same time from other window with the same connection any query it works.

                    When i connect to a server via TCP it will crash.
                    Edit: Its also with localhost, but the time is a bit longer ;(

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      Can you trigger also that when using an application that's not using the QSql** classes ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        ckvsoft
                        wrote on last edited by
                        #14

                        I think i have found a solution ;-) Some Test will be good. I will enhance my tests.
                        The Idea i found by reading http://doc.qt.io/qt-5/threads-modules.html

                        Just my Application worked since 2015 with QSQLITE without troubles. But some users will also use MySQL.

                        For the solution i have adapted a database manager for my requirement.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #15

                          So you're using multiple threads to write to your database ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          C 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            So you're using multiple threads to write to your database ?

                            C Offline
                            C Offline
                            ckvsoft
                            wrote on last edited by ckvsoft
                            #16

                            @SGaist
                            Yes. I Import JSON Files with an Import Walter Thread. Wenn a File is copied in a Directory it will Import and created new sql entries.
                            Nur Why SQlite has no Troubles?
                            I will also Move long Working Stuff to thread

                            Ob they GUI you also can do some queries by clicking Buttons

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #17

                              I'd say pure luck.

                              Are you creating one connection per thread like suggested in the documentation ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              1
                              • C Offline
                                C Offline
                                ckvsoft
                                wrote on last edited by ckvsoft
                                #18

                                @SGaist
                                Yes. The DatabaseManager save the connections per thread into a

                                QHash<QThread*, QHash<QString, QSqlDatabase> > 
                                
                                

                                I have only one thread at a time wich write to the database. All others max. 4 to only select
                                Sorry for my "Austrian English" ;-)

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #19

                                  Can you show how your are setting up the connections ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  1
                                  • C Offline
                                    C Offline
                                    ckvsoft
                                    wrote on last edited by ckvsoft
                                    #20

                                    @SGaist

                                    The first connection is in my first post
                                    Than for every connection i call

                                    QSqlDatabase dbc = DatabaseManager::database("CN");
                                    QSqlQuery query(dbc)
                                    .
                                    .
                                    

                                    .

                                    #include "databasemanager.h"
                                    
                                    #include <QSqlDatabase>
                                    #include <QMutexLocker>
                                    #include <QThread>
                                    #include <QSqlError>
                                    #include <QDebug>
                                    
                                    QMutex DatabaseManager::s_databaseMutex;
                                    QHash<QThread*, QHash<QString, QSqlDatabase> > DatabaseManager::s_instances;
                                    
                                    QSqlDatabase DatabaseManager::database(const QString& connectionName)
                                    {
                                        QMutexLocker locker(&s_databaseMutex);
                                        QThread *thread = QThread::currentThread();
                                    
                                        // if we have a connection for this thread, return it
                                        QHash<QThread*, QHash<QString, QSqlDatabase> >::Iterator it_thread = s_instances.find(thread);
                                        if (it_thread != s_instances.end()) {
                                            QHash<QString, QSqlDatabase>::iterator it_conn = it_thread.value().find(connectionName);
                                            if (it_conn != it_thread.value().end()) {
                                                QSqlDatabase connection = it_conn.value();
                                    //            qDebug() << "Function Name: " << Q_FUNC_INFO << " found SQL connection instances Thread: " << thread->currentThreadId() << " Name: " << connectionName;
                                                if (connection.isValid())
                                                    return it_conn.value();
                                            }
                                        }
                                    
                                        // otherwise, create a new connection for this thread
                                        QSqlDatabase connection = QSqlDatabase::cloneDatabase(
                                                                      QSqlDatabase::database(connectionName),
                                                                      QString("%1_%2").arg(connectionName).arg((int)thread));
                                    
                                        // open the database connection
                                        // initialize the database connection
                                        if (!connection.open()) {
                                            // Todo: Exeption Handling
                                            qCritical() << "Function Name: " << Q_FUNC_INFO << connection.lastError().text();
                                            return connection;
                                        }
                                    
                                        qDebug() << "Function Name: " << Q_FUNC_INFO << " new SQL connection instances Thread: " << thread->currentThreadId() << " Name: " << connectionName;
                                    
                                        s_instances[thread][connectionName] = connection;
                                        return connection;
                                    }
                                    
                                    #ifndef DATABASEMANAGER_H
                                    #define DATABASEMANAGER_H
                                    
                                    #include "qrkcore_global.h"
                                    
                                    #include <QMutex>
                                    #include <QHash>
                                    #include <QSqlDatabase>
                                    
                                    class QThread;
                                    
                                    class QRK_EXPORT DatabaseManager
                                    {
                                        public:
                                            static QSqlDatabase database(const QString& connectionName = QLatin1String(QSqlDatabase::defaultConnection));
                                        private:
                                            static QMutex s_databaseMutex;
                                            static QHash<QThread*, QHash<QString, QSqlDatabase>> s_instances;
                                    
                                    };
                                    
                                    #endif // DATABASEMANAGER_H
                                    

                                    I found the code and adapted it for my requirement.

                                    1 Reply Last reply
                                    0
                                    • C Offline
                                      C Offline
                                      ckvsoft
                                      wrote on last edited by
                                      #21

                                      So. I made some tests with create more than 1000 receipts and do concurrent imports with 10000 Products and do some select. I seems it works now without any troubles localhost and IP also over slow connection over the internet.

                                      i think it fix my problem.
                                      lg chris

                                      1 Reply Last reply
                                      0

                                      • Login

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