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. [SOLVED] Strange Sigsev On QSqlQuery.exec();

[SOLVED] Strange Sigsev On QSqlQuery.exec();

Scheduled Pinned Locked Moved General and Desktop
qlistqsqlqueryqt 5.4.2qt 5.3.2
9 Posts 2 Posters 3.3k 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.
  • B Offline
    B Offline
    Brochadinho
    wrote on 17 Jun 2015, 15:08 last edited by Brochadinho
    #1
    QList<Relatorio*> acessodb::obterRelatorioMes(qulonglong idEmpresa, qulonglong idCliente,QString mesAno) {
        QSqlQuery query(QSqlDatabase::database());
    
        QList<Relatorio*> listaRelatorios;
        query.prepare("SELECT id,diario,numero_lancamento,data,"
                      "contrapartida,debito,credito,descricao,numero_documento,"
                      "relatorio_mes_ano,tipo_documento,conta FROM relatorio_"+QString::number(idEmpresa)+"_"+QString::number(idCliente)+" "
                      "Where relatorio_mes_ano='"+mesAno+"'");
       if (query.exec()) {
            while (query.next()) {
                listaRelatorios.append(queryToRelatorio(query));
            }
            return listaRelatorios;
        }
    

    I was making some change on the aplication, when this part started to give me sigsevs. I didn't changed this part, so to me, this looks awkard. If i run in qt 5.4 gcc, this just give me sigsev on the "if (query.exec()) ". If i do the same thing but compile in the 5.3.2, give me error i the same line, but on app output i have "corrupted double-linked list: 0x0000000000b6b2f0 ***".

    I run it with valgrid and no error =S

    Can anyone give a clue of what is happening.

    btw, this new look of the forum, for me doesn't work at all. The forum of qt-project had a most better interface. i hope that this design end tomorrow.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Brochadinho
      wrote on 17 Jun 2015, 15:41 last edited by
      #2

      now i even more confuse. Just tried to run with valgrid Memory Analyzer with GDB, and it works perfectly. But when i run in normal debug or release, SigSev on the query.exec(). The result of the query, will retrieve 980 records.

      if some one can give me a help, i'm entering the total despair mode.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Brochadinho
        wrote on 17 Jun 2015, 15:49 last edited by Brochadinho
        #3

        i just tried to

        if (query.exec("SELECT id,diario,numero_lancamento,data,"
                           "contrapartida,debito,credito,descricao,numero_documento,"
                           "relatorio_mes_ano,tipo_documento,conta FROM relatorio_"+QString::number(idEmpresa)+"_"+QString::number(idCliente)+" "
                           "Where relatorio_mes_ano='"+mesAno+"'")) 
        

        and i get the same sigsev on the same exec()

        ---- edit

        Now i have the app running by the valgrind and it works fine! but if i go debug or release, i got again on sigsevs.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 17 Jun 2015, 17:41 last edited by SGaist
          #4

          Hi,

          Are you sure it's the exec that triggers that ? I mean, what does the backtrace tell you ?

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

          B 1 Reply Last reply 18 Jun 2015, 09:46
          0
          • S SGaist
            17 Jun 2015, 17:41

            Hi,

            Are you sure it's the exec that triggers that ? I mean, what does the backtrace tell you ?

            B Offline
            B Offline
            Brochadinho
            wrote on 18 Jun 2015, 09:46 last edited by
            #5

            @SGaist

            thanks for reply. i look at the stack and it seems that come from there. But i will leave a printscreen. https://i.imgur.com/PDlOs61.jpg What can i do to better debug this?

            1 Reply Last reply
            0
            • B Offline
              B Offline
              Brochadinho
              wrote on 18 Jun 2015, 14:26 last edited by
              #6

              now it becomes even weird. For some reason, when executed with different parameter, it run with no problem. Its seems to be specific for some idEmpresa.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 18 Jun 2015, 14:33 last edited by
                #7

                Are you then trying to access tables that doesn't exist ?

                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
                • B Offline
                  B Offline
                  Brochadinho
                  wrote on 18 Jun 2015, 16:53 last edited by
                  #8

                  @SGaist
                  nop, i put the query to output, just to run it on postgres directly, and it works ok.
                  With valgrind it works, when i try the same exe without valgrind, i got sigsev.
                  When i try mode some code just to expect somthing diferent, i got "currupted double-linked list" . I Fear that is some memory management that in not doing right.

                  this block, deletes the outdate records.
                  then calls the function that create new records.
                  and for last i load the recent created records.

                      acessodb::apagarLinhasDesactualizadas(idEmpresa, idCliente, mesAno);//limpar registo antigos
                      gerarRelatorio(idEmpresa,idCliente,mesAno);
                      //
                      QList<Relatorio*>listaRelatorio;
                      listaRelatorio=acessodb::obterRelatorioMes(idEmpresa,idCliente,mesAno); 
                  

                  Do you have any sugestion to try enchant my debug, so i can discover what is happening?

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    Brochadinho
                    wrote on 18 Jun 2015, 17:36 last edited by
                    #9

                    at funtion gerarRelatorio i swap the qDeleteAll on line down(original position). and it worked.

                        qDebug()<<"Documentos processados para a Tabela de Relatorio";
                        acessodb::setDataUltimoRelatorio(idEmpresa,idCliente);
                        qDeleteAll(listaDocumentos);
                        listaDocumentos.clear();
                        delete modelo;
                        return true;
                    

                    I now will upload to my test server, and see what happens.
                    i doesn't care any more about what is causing the problem, i just hope that is solved.

                    1 Reply Last reply
                    0

                    3/9

                    17 Jun 2015, 15:49

                    topic:navigator.unread, 6
                    • Login

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