Results 1 to 9 of 9

Thread: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Qt Code:
    1. Conditional jump or move depends on uninitialised value(s)
    2. in Test::Test(QNetworkReply*, Test::CallType) in respond.cpp:16
    3. 1: /usr/lib64/qt4/libQtNetwork.so.4.7.4
    4. 2: QIODevice::read(char*, long long) in /usr/lib64/qt4/libQtCore.so.4.7.4
    5. 3: QIODevice::readAll() in /usr/lib64/qt4/libQtCore.so.4.7.4
    6. 4: Test::Test(QNetworkReply*, Test::CallType) in <a href="file:///home/me/workspace/desktop/Desktop/respond.cpp:16" >respond.cpp:16</a>
    7. .
    8. .
    9. .
    To copy to clipboard, switch view to plain text mode 


    My Test construct class ...in short... looks like this:

    Qt Code:
    1. Test::Test(QNetworkReply *reply)
    2. {
    3. if(reply)
    4. {
    5. QByteArray data = reply->readAll(); <<<<<< line 16
    6. reply->deleteLater();
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for looking.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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.
    Last edited by migel; 2nd March 2012 at 11:34.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default 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()).
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: conditional jump or move depends on uninitialised value(s) libQtNetwork.so.4.7.4

    yeah, I tried delete reply. Did not help.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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

    Qt Code:
    1. Conditional jump or move depends on uninitialised value(s)
    2. in Test::Codes(int const&amp;) in test.cpp:32
    3. 1: Test::Codes(int const&amp;) in test.cpp:32
    4. 2: Test::VerifyTest() in test.cpp:44
    To copy to clipboard, switch view to plain text mode 

    the header
    Qt Code:
    1. #include <QNetworkReply>
    2.  
    3. class Test
    4. {
    5.  
    6. public:
    7.  
    8. Test();
    9. Test(QNetworkReply *reply);
    10. const QByteArray Data() const;
    11. int Code() const;
    12. bool IsSuccess() const;
    13. bool IsError() const;
    14.  
    15. private:
    16.  
    17. void VerifyTest();
    18. bool Codes(const int &code);
    19.  
    20. QByteArray _respondData;
    21. QString _respondError;
    22. int _respondCode;
    23. bool _success;
    24. QString _respondUrl;
    25. };
    To copy to clipboard, switch view to plain text mode 


    the source
    Qt Code:
    1. #include "test.h"
    2.  
    3. Test::Test() :
    4. _respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
    5. {
    6. }
    7.  
    8. Test::Test(QNetworkReply *reply) :
    9. _respondData(""), _respondError(""), _respondCode(0), _success(false), _respondUrl("")
    10. {
    11. if(reply)
    12. {
    13. _respondData = reply->readAll(); << line 16
    14. _respondError = reply->errorString();
    15. _respondCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute).toInt();
    16. _respondUrl = reply->url().toString();
    17.  
    18. VerifyTest();
    19. reply->deleteLater();
    20. }
    21. }
    22.  
    23. bool Test::Codes(const int &code)
    24. {
    25. switch( code ) << line 32
    26. {
    27. case 200:
    28. return true;
    29. default:
    30. return false;
    31. }
    32. }
    33.  
    34. void Test::VerifyTest()
    35. {
    36. if (Codes(_respondCode)) << line 44
    37. {
    38. _success = true;
    39. }
    40. else
    41. {
    42. // false ...
    43. }
    44. }
    45.  
    46. const QByteArray Test::Data() const
    47. {
    48. return _respondData;
    49. }
    50.  
    51. int Test::Code() const
    52. {
    53. return _respondCode;
    54. }
    55.  
    56. bool Test::IsSuccess() const
    57. {
    58. return _success;
    59. }
    60.  
    61. bool Test::IsError() const
    62. {
    63. return !_success;
    64. }
    To copy to clipboard, switch view to plain text mode 


    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
    Last edited by migel; 2nd March 2012 at 12:52.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

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

Similar Threads

  1. QSlider: direct jump
    By mpi in forum Qt Programming
    Replies: 2
    Last Post: 22nd July 2011, 07:02
  2. Progress jump using QNetworkReply and SSL
    By danc81 in forum Qt Programming
    Replies: 4
    Last Post: 5th November 2009, 19:20
  3. Linking error: libQtNetwork.so: undefined reference to `_freeifaddrs'
    By dacla in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 21st April 2008, 22:26
  4. do Qt4 installation depends on gcc version
    By quickNitin in forum Installation and Deployment
    Replies: 3
    Last Post: 3rd October 2006, 06:14
  5. depends
    By Everall in forum Installation and Deployment
    Replies: 5
    Last Post: 7th February 2006, 18:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.