Results 1 to 5 of 5

Thread: valgrind warning in Qt

  1. #1
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    20
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default valgrind warning in Qt

    I use Qt 3.3.2, gcc 3.3.3. I wrote simple xml parsing test.

    Qt Code:
    1. #include <qxml.h>
    2.  
    3. int main( int argc, char** argv)
    4. {
    5. QString s = "<xml></xml>";
    6.  
    7. input.setData(s);
    8.  
    9. if (!reader.parse(&input, FALSE))
    10. return 1;
    11.  
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    If to compile this test and run under valgrind the following warning will be shown:

    ==10134== Conditional jump or move depends on uninitialised value(s)
    ==10134== at 0x446B9CE: QXmlSimpleReader:arseElement() (in /usr/local/qt-3.3.2-3.3.3/lib/libqt-mt.so.3.3.2)
    ==10134== by 0x446B200: QXmlSimpleReader:arseBeginOrContinue(int, bool) (in /usr/local/qt-3.3.2-3.3.3/lib/libqt-mt.so.3.3.2)
    ==10134== by 0x446AEE1: QXmlSimpleReader:arse(QXmlInputSource const*, bool) (in /usr/local/qt-3.3.2-3.3.3/lib/libqt-mt.so.3.3.2)
    ==10134== by 0x8048D52: main (main.cpp:<this line number points to reader.parse(..) string)

    Is it Qt bug and how to avoid it?

    Thanks,
    Vitaly
    Last edited by vitaly; 6th June 2006 at 15:33.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: valgrind warning in Qt

    Quote Originally Posted by vitaly
    If to compile this test and run under valgrind the following warning will be shown:

    ==10134== Conditional jump or move depends on uninitialised value(s)
    ==10134== at 0x446B9CE: QXmlSimpleReader:arseElement() (in /usr/local/qt-3.3.2-3.3.3/lib/libqt-mt.so.3.3.2)
    ==10134== by 0x446B200: QXmlSimpleReader:arseBeginOrContinue(int, bool) (in /usr/local/qt-3.3.2-3.3.3/lib/libqt-mt.so.3.3.2)
    ==10134== by 0x446AEE1: QXmlSimpleReader:arse(QXmlInputSource const*, bool) (in /usr/local/qt-3.3.2-3.3.3/lib/libqt-mt.so.3.3.2)
    ==10134== by 0x8048D52: main (main.cpp:<this line number points to reader.parse(..) string)

    Is it Qt bug and how to avoid it?
    There's not much you can do about it, unless you stab the QXmlSimpleReader sources. Valgrind just doesn't like the way it is written..
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: valgrind warning in Qt

    You can use valgrind's options "gen-suppressions" and "suppressions" to suppress any errors which are not interesting for you.
    Qt Code:
    1. # valgrind --gen-suppressions=yes ./app
    2. # valgrind --suppressions=suppressions.err ./app
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    20
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: valgrind warning in Qt

    Thanks for reply!

    My project has only this Valgrind warning at the moment. But our QA group doesn't like it. They suspect me of making a bug. I thought to investigate the problem but it may need much timе. With high probability (and with your help in answering me, of course) I suspect Qt in this warning, so I will demonstrate our QA that it is not my "bug" by presenting the test described above.

    Thanks a lot
    Vitaly

  5. #5
    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: valgrind warning in Qt

    It's not really a bug. Valgrind is too stupid to guess from the context that the variable will be initialised. Take this example:

    Qt Code:
    1. int i;
    2. if(something){
    3. i=7;
    4. }
    5. if(!something){
    6. i=5;
    7. }
    8. if(i==5){
    9. // ...
    10. } else {
    11. // ...
    12. }
    To copy to clipboard, switch view to plain text mode 

    Now from machine's point of view, i may be uninitialised during "if(i==5)" test, but based on the context you'll notice that i will always be initialised, either as 7 or as 5. So there's no bug here. And this could and probably is the same case with the xml parser.

Similar Threads

  1. Qt/Embedded Installation error during make
    By mahe2310 in forum Installation and Deployment
    Replies: 5
    Last Post: 7th September 2006, 04:05
  2. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23
  3. linking libraries
    By JustaStudent in forum Newbie
    Replies: 29
    Last Post: 2nd May 2006, 08:30
  4. a Text Editor with line numbers...
    By fullmetalcoder in forum Qt Programming
    Replies: 47
    Last Post: 5th April 2006, 11:10
  5. warning message on compile not understood
    By impeteperry in forum Qt Programming
    Replies: 13
    Last Post: 23rd January 2006, 23:36

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.