簡體   English   中英

QTcpSocket上的Qt / C ++ / Valgrind無效Readsize為8

[英]Qt/C++/Valgrind Invalid Readsize of 8 on QTcpSocket disconnect

我在Qt / C ++程序上運行valgrind並收到此錯誤:

Invalid read of size 8
  in TelnetConnection::disconnectClient() in telnetserver/telnetconnection.cpp:188

188行是下面的waitForDisconnected行:

void TelnetConnection::disconnectClient()
{
    tcpSocketPtr->disconnectFromHost();
    tcpSocketPtr->waitForDisconnected();
}

我不確定這個錯誤是什么意思,但是我該如何解決呢? 還是這超出了我的控制范圍? (一個Qt問題)?

我不確定是否相關,但是我得到的唯一其他錯誤是:

384 bytes in 1 blocks are possibly lost in loss record 5,342 of 5,972
  in TelnetServer::incomingConnection(long long) in telnetserver/telnetserver.cpp:22

錯誤行是下面的Start():

void TelnetServer::incomingConnection(qintptr socketDescriptor)
{
    TelnetConnection *thread = new TelnetConnection(socketDescriptor, this);
    connect(thread, SIGNAL(shutdownRequested()), m_controller, SLOT(shutdownCommandIssued()));
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    connect(m_controller, SIGNAL(shutingdown()), thread, SLOT(shutdownConnection()));
    thread->start();
}

再次...此啟動功能如何導致內存泄漏? 還是“可能丟失”一詞表示確實可以?

有關最佳答案,請參見上面的塞巴斯蒂安評論。 基本上,讀/寫錯誤是由於即使關閉套接字后仍繼續向套接字發送流量(關閉不會停止所有流量)。 解決方法是在刪除線程時刪除套接字。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM