Important: Please read the Qt Code of Conduct -

Qt C++ code crash (ASSERT: *node == e)

  • What is reason behind the below error message

    ASSERT: "*node == e || (*node)->next" in file ....\include/QtCore/../../src/corelib/tools/qhash.h, line 918
    11:43:02: The program has unexpectedly finished.
    11:43:02: The process was ended forcefully.

    I have tcp client socket which received 74 bytes of data from server @ 20mSec interval.
    I'm collecting the data using queue and emitting @ every 50mSec interval to other C++ backend class which does processing of the data.
    I'm doubtful if the processing on the backend class is causing the issue?
    How to debug the crash and collect crash log?

  • Lifetime Qt Champion

    @Vyuvaraj said in Qt C++ code crash (ASSERT: *node == e):

    How to debug the crash and collect crash log?

    Use a debugger and take a look at the backtrace to see where it comes from. Are you using threads?

  • Code Please

  • @fcarney

    bool m_quit = false;
    bool m_InProcess = false;
    QTcpSocket *m_sock = nullptr;
    tpClient::tpClient(QObject *parent) : QThread(parent) {
       m_InProcess = false;
       m_sock = new QTcpSocket(this);
       connect(m_sock, SIGNAL(connected()), this, SLOT(connected()));
       connect(m_sock, SIGNAL(disconnected()), this, SLOT(disconnected()));
       connect(m_sock, SIGNAL(readyRead()), this, SLOT(readyRead()));
    void tpClient::connected() { if(!isRunning()){start();} }
    void tpClient::readyRead() { m_dataInQ.push(m_sock->readAll()); }
    void tpClient::run(void) {
      qDebug() <<  "Thread is Running...";
        while(!m_dataInQ.empty() && !m_InProcess){
        /* This will allow the rendering engine to achieve a consistent 60 frames-per-second refresh rate.
            60 FPS means that there is approximately 16 milliseconds.
            Provide 2 times more for safety */
        if(m_mutex.tryLockForRead(1000)) {
          QByteArray data = m_dataInQ.front();

  • Lifetime Qt Champion

    Please read the QThread docs - you're doing it wrong, the examples and docs give you a good starting point...

Log in to reply