Qt World Summit: Submit your Presentation

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

  • 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,"
                      "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()) {
            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.

  • 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.

  • i just tried to

    if (query.exec("SELECT id,diario,numero_lancamento,data,"
                       "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.

  • Lifetime Qt Champion


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

  • @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?

  • 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.

  • Lifetime Qt Champion

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

  • @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

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

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

        qDebug()<<"Documentos processados para a Tabela de Relatorio";
        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.