conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
I am analyzing my code using valgrind tool for QtCreator and there is some leak which I don't understand and I am assuming this is coming from QT and not from my code.
Code:
Conditional jump or move depends on uninitialised value(s)
in Test::Test(QNetworkReply*, Test::CallType) in respond.cpp:16
1: /usr/lib64/qt4/libQtNetwork.so.4.7.4
2: QIODevice::read(char*,
long long) in
/usr
/lib64
/qt4
/libQtCore.
so.4.7.4
3: QIODevice::readAll() in
/usr
/lib64
/qt4
/libQtCore.
so.4.7.4
4: Test::Test(QNetworkReply*, Test::CallType) in <a href="file:///home/me/workspace/desktop/Desktop/respond.cpp:16" >respond.cpp:16</a>
.
.
.
My Test construct class ...in short... looks like this:
Code:
Test::Test(QNetworkReply *reply)
{
if(reply)
{
QByteArray data
= reply
->readAll
(); <<<<<< line
16 reply->deleteLater();
}
}
Thanks for looking.
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
My guess is that valgrind is seeing a leak here, since you are using deleteLater(), which means you are not delete the reply object your self.
Are you running the valgrid session to the end (that is, so that the application finishes) or do you break the application at some point?
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
Test class is a part of another thread which running in the QTimer loop. I let the app run for a while then quit it normally, closing threads and the app. But the logs appearing during the run time.
Added after 10 minutes:
I have tried delete the reply just for testing which is not safe to do it.
Same error.
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
I think this is a false positive.
To make sure you can try deleting the reply object in the thread it was created in. (just as a test, your code is the correct way to do it with deleteLater()).
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
yeah, I tried delete reply. Did not help.
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
Can you show us the definition of your Test class?
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
sure
There is one more error in this class in line 32
Code:
Conditional jump or move depends on uninitialised value(s)
in Test::Codes(int const&) in test.cpp:32
1: Test::Codes(int const&) in test.cpp:32
2: Test::VerifyTest() in test.cpp:44
the header
Code:
#include <QNetworkReply>
class Test
{
public:
Test();
Test(QNetworkReply *reply);
int Code() const;
bool IsSuccess() const;
bool IsError() const;
private:
void VerifyTest();
bool Codes(const int &code);
int _respondCode;
bool _success;
};
the source
Code:
#include "test.h"
Test::Test() :
_respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
{
}
Test::Test(QNetworkReply *reply) :
_respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
{
if(reply)
{
_respondData = reply->readAll(); << line 16
_respondError = reply->errorString();
_respondCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt();
_respondUrl = reply->url().toString();
VerifyTest();
reply->deleteLater();
}
}
bool Test::Codes(const int &code)
{
switch( code ) << line 32
{
case 200:
return true;
default:
return false;
}
}
void Test::VerifyTest()
{
if (Codes(_respondCode)) << line 44
{
_success = true;
}
else
{
// false ...
}
}
{
return _respondData;
}
int Test::Code() const
{
return _respondCode;
}
bool Test::IsSuccess() const
{
return _success;
}
bool Test::IsError() const
{
return !_success;
}
Added after 5 minutes:
You will notice line 16 is different.
_respondData = reply->readAll(); << line 16
But the error remains when I change to
QByteArray respondData = reply->readAll(); << line 16
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
Is this your actual code? Because the error message claims the constructor takes two parameters while in your code it has only one parameter. Does the error go away if you add it?
Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4
I have removed Test::CallType this is the enum param and its not the case.