Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Valgrind Memcheck tool issue

Valgrind Memcheck tool issue

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
17 Posts 4 Posters 4.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @nagaraj_r Does this app run properly without Valgrind?

    N Offline
    N Offline
    nagaraj_r
    wrote on last edited by
    #4

    @jsulm Yes, it is running fine - no error msg displayed, without memcheck analyzer.

    1 Reply Last reply
    0
    • JonBJ JonB

      @nagaraj_r said in Valgrind Memcheck tool issue:

      Qt version : 5.0

      Additional to @jsulm (it's vital you reply to him), do you really need to be using as old a Qt version as 5.0?

      And, further, the Qt Creator is only an interface to your own valgrind which you fetched/installed, how old is that?

      N Offline
      N Offline
      nagaraj_r
      wrote on last edited by
      #5

      @JonB Sorry, the exact Qt version currently using is 5.10.0 and the valgrind(3.4) which we fetched using apt-get.

      JonBJ 1 Reply Last reply
      0
      • N nagaraj_r

        @JonB Sorry, the exact Qt version currently using is 5.10.0 and the valgrind(3.4) which we fetched using apt-get.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #6

        @nagaraj_r
        I can only say I am Ubuntu 19.04, Qt 5.12.2 & valgrind 3.14.0, and all works fine when I use it.

        You could (i.e should) test your app under valgrind outside of Qt Creator to see if you can eliminate that from being the issue.

        If your code is that simple/small, we wouldn't mind seeing your source just to make sure nothing amiss (valgrind could show up problems you don't see without it)....

        N 1 Reply Last reply
        0
        • JonBJ JonB

          @nagaraj_r
          I can only say I am Ubuntu 19.04, Qt 5.12.2 & valgrind 3.14.0, and all works fine when I use it.

          You could (i.e should) test your app under valgrind outside of Qt Creator to see if you can eliminate that from being the issue.

          If your code is that simple/small, we wouldn't mind seeing your source just to make sure nothing amiss (valgrind could show up problems you don't see without it)....

          N Offline
          N Offline
          nagaraj_r
          wrote on last edited by
          #7

          @JonB I tried to run the valgrind memcheck tool outside of Qt creator IDE in command prompt, but still it couldn't find the memory leak in the program.

          Sample code is as below,

          main.cpp:
          #include "mainwindow.h"
          #include <QApplication>

          int main(int argc, char *argv[])
          {
          QApplication a(argc, argv);
          int *b = new int[10];
          MainWindow w;
          w.show();
          return a.exec();
          }

          mainwindow.cpp:
          #include "mainwindow.h"
          #include "ui_mainwindow.h"

          MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
          {
          int *b = new int[10];
          ui->setupUi(this);
          }

          MainWindow::~MainWindow()
          {
          delete ui;
          }

          output of the memcheck tool is as below, when executed from command prompt, where it could not list the leaked memory of 40 bytes each in main() and MainWindow()

          707a19e2-b967-40d2-bf01-eada5670863e-image.png

          ee47e2e0-ec49-4053-8e9e-43596c3daa37-image.png

          JonBJ 1 Reply Last reply
          0
          • N nagaraj_r

            @JonB I tried to run the valgrind memcheck tool outside of Qt creator IDE in command prompt, but still it couldn't find the memory leak in the program.

            Sample code is as below,

            main.cpp:
            #include "mainwindow.h"
            #include <QApplication>

            int main(int argc, char *argv[])
            {
            QApplication a(argc, argv);
            int *b = new int[10];
            MainWindow w;
            w.show();
            return a.exec();
            }

            mainwindow.cpp:
            #include "mainwindow.h"
            #include "ui_mainwindow.h"

            MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
            {
            int *b = new int[10];
            ui->setupUi(this);
            }

            MainWindow::~MainWindow()
            {
            delete ui;
            }

            output of the memcheck tool is as below, when executed from command prompt, where it could not list the leaked memory of 40 bytes each in main() and MainWindow()

            707a19e2-b967-40d2-bf01-eada5670863e-image.png

            ee47e2e0-ec49-4053-8e9e-43596c3daa37-image.png

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #8

            @nagaraj_r
            Not sure what I can say. I use valgrind under Linux (Ubuntu 19.04), it hasn't "crashed" on me.

            I can see nothing wrong with your code per se. It looks like valgrind is barfing on what it regards as an Illegal instruction (core dumped). Somewhere down in the guts of Qt directory/regular expression/random generator (goodness knows why). It says it could be valgrind's fault and you have to report it!

            Try on a still simpler program (e.g. just a main()). Not that it will help you much. You have valgrind-3.11.0, I have valgrind-3.14.0. You could Google for valgrind crashes....

            N 1 Reply Last reply
            0
            • JonBJ JonB

              @nagaraj_r
              Not sure what I can say. I use valgrind under Linux (Ubuntu 19.04), it hasn't "crashed" on me.

              I can see nothing wrong with your code per se. It looks like valgrind is barfing on what it regards as an Illegal instruction (core dumped). Somewhere down in the guts of Qt directory/regular expression/random generator (goodness knows why). It says it could be valgrind's fault and you have to report it!

              Try on a still simpler program (e.g. just a main()). Not that it will help you much. You have valgrind-3.11.0, I have valgrind-3.14.0. You could Google for valgrind crashes....

              N Offline
              N Offline
              nagaraj_r
              wrote on last edited by
              #9

              @JonB Thanks for the response. After upgrading to Valgrind version 3.14.0, tried to analyze the same simple qt application(source for which shared earlier thread), it hasn't crashed. this time.

              But it shows lot of false positive memory leak issues in gcc libraries and Qt libraries which we don't want to report.
              Could you please let me know, how to suppress these errors.

              6,773 (232 direct, 6,541 indirect) bytes in 1 blocks are definitely lost in loss record 7,739 of 7,769
              ==16231== at 0x4C2FF6C: calloc (vg_replace_malloc.c:752)
              ==16231== by 0xE606DFF: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
              ==16231== by 0xE61120E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
              ==16231== by 0xE6116E2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
              ==16231== by 0xE605179: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
              ==16231== by 0xE5EF80E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
              ==16231== by 0xDD2D137: ??? (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5DBus.so.5.10.0)
              ==16231== by 0x591EB20: QObject::event(QEvent
              ) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
              ==16231== Memcheck, a memory error detector
              ==16231== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
              ==16231== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
              ==16231== Command: /home/dinesh/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/test
              ==16231== Parent PID: 2323
              ==16231==
              ==16231==
              ==16231== HEAP SUMMARY:
              ==16231== in use at exit: 1,563,805 bytes in 19,588 blocks
              ==16231== total heap usage: 145,872 allocs, 126,284 frees, 88,031,708 bytes allocated
              ==16231== by 0x58F29E2: QCoreApplication::notifyInternal2(QObject
              , QEvent
              ) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
              ==16231== by 0x58F548A: QCoreApplicationPrivate::sendPostedEvents(QObject
              , int, QThreadData*) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
              ==16231== by 0x5947562: ??? (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
              ==16231== by 0x9F42196: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)

              ==16231== LEAK SUMMARY:
              ==16231== definitely lost: 840 bytes in 6 blocks
              ==16231== indirectly lost: 12,986 bytes in 78 blocks
              ==16231== possibly lost: 3,752 bytes in 33 blocks
              ==16231== still reachable: 1,464,123 bytes in 18,800 blocks
              ==16231== of which reachable via heuristic:
              ==16231== length64 : 4,904 bytes in 80 blocks
              ==16231== newarray : 2,096 bytes in 51 blocks
              ****

              Pablo J. RoginaP JonBJ 2 Replies Last reply
              0
              • N nagaraj_r

                @JonB Thanks for the response. After upgrading to Valgrind version 3.14.0, tried to analyze the same simple qt application(source for which shared earlier thread), it hasn't crashed. this time.

                But it shows lot of false positive memory leak issues in gcc libraries and Qt libraries which we don't want to report.
                Could you please let me know, how to suppress these errors.

                6,773 (232 direct, 6,541 indirect) bytes in 1 blocks are definitely lost in loss record 7,739 of 7,769
                ==16231== at 0x4C2FF6C: calloc (vg_replace_malloc.c:752)
                ==16231== by 0xE606DFF: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                ==16231== by 0xE61120E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                ==16231== by 0xE6116E2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                ==16231== by 0xE605179: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                ==16231== by 0xE5EF80E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                ==16231== by 0xDD2D137: ??? (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5DBus.so.5.10.0)
                ==16231== by 0x591EB20: QObject::event(QEvent
                ) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                ==16231== Memcheck, a memory error detector
                ==16231== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
                ==16231== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
                ==16231== Command: /home/dinesh/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/test
                ==16231== Parent PID: 2323
                ==16231==
                ==16231==
                ==16231== HEAP SUMMARY:
                ==16231== in use at exit: 1,563,805 bytes in 19,588 blocks
                ==16231== total heap usage: 145,872 allocs, 126,284 frees, 88,031,708 bytes allocated
                ==16231== by 0x58F29E2: QCoreApplication::notifyInternal2(QObject
                , QEvent
                ) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                ==16231== by 0x58F548A: QCoreApplicationPrivate::sendPostedEvents(QObject
                , int, QThreadData*) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                ==16231== by 0x5947562: ??? (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                ==16231== by 0x9F42196: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)

                ==16231== LEAK SUMMARY:
                ==16231== definitely lost: 840 bytes in 6 blocks
                ==16231== indirectly lost: 12,986 bytes in 78 blocks
                ==16231== possibly lost: 3,752 bytes in 33 blocks
                ==16231== still reachable: 1,464,123 bytes in 18,800 blocks
                ==16231== of which reachable via heuristic:
                ==16231== length64 : 4,904 bytes in 80 blocks
                ==16231== newarray : 2,096 bytes in 51 blocks
                ****

                Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #10

                @nagaraj_r could you please provide the command line / options you used with Valgrind?

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                N 1 Reply Last reply
                0
                • N nagaraj_r

                  @JonB Thanks for the response. After upgrading to Valgrind version 3.14.0, tried to analyze the same simple qt application(source for which shared earlier thread), it hasn't crashed. this time.

                  But it shows lot of false positive memory leak issues in gcc libraries and Qt libraries which we don't want to report.
                  Could you please let me know, how to suppress these errors.

                  6,773 (232 direct, 6,541 indirect) bytes in 1 blocks are definitely lost in loss record 7,739 of 7,769
                  ==16231== at 0x4C2FF6C: calloc (vg_replace_malloc.c:752)
                  ==16231== by 0xE606DFF: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                  ==16231== by 0xE61120E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                  ==16231== by 0xE6116E2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                  ==16231== by 0xE605179: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                  ==16231== by 0xE5EF80E: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.6)
                  ==16231== by 0xDD2D137: ??? (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5DBus.so.5.10.0)
                  ==16231== by 0x591EB20: QObject::event(QEvent
                  ) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                  ==16231== Memcheck, a memory error detector
                  ==16231== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
                  ==16231== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
                  ==16231== Command: /home/dinesh/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/test
                  ==16231== Parent PID: 2323
                  ==16231==
                  ==16231==
                  ==16231== HEAP SUMMARY:
                  ==16231== in use at exit: 1,563,805 bytes in 19,588 blocks
                  ==16231== total heap usage: 145,872 allocs, 126,284 frees, 88,031,708 bytes allocated
                  ==16231== by 0x58F29E2: QCoreApplication::notifyInternal2(QObject
                  , QEvent
                  ) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                  ==16231== by 0x58F548A: QCoreApplicationPrivate::sendPostedEvents(QObject
                  , int, QThreadData*) (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                  ==16231== by 0x5947562: ??? (in /opt/Qt5.10.0/5.10.0/gcc_64/lib/libQt5Core.so.5.10.0)
                  ==16231== by 0x9F42196: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)

                  ==16231== LEAK SUMMARY:
                  ==16231== definitely lost: 840 bytes in 6 blocks
                  ==16231== indirectly lost: 12,986 bytes in 78 blocks
                  ==16231== possibly lost: 3,752 bytes in 33 blocks
                  ==16231== still reachable: 1,464,123 bytes in 18,800 blocks
                  ==16231== of which reachable via heuristic:
                  ==16231== length64 : 4,904 bytes in 80 blocks
                  ==16231== newarray : 2,096 bytes in 51 blocks
                  ****

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #11

                  @nagaraj_r

                  it hasn't crashed. this time.

                  That's an important start!

                  All I know is: when I run Analyze > Valgrind Memory Analyzer from Creator I accept the default filter on the Memcheck window which is having External Errors unchecked. That removes 32 warnings about internal Qt stuff, and I don't get any false positives left. (I do unfortunately get "false negatives", in that valgrind can miss some leaks. but that's another matter.)

                  N 1 Reply Last reply
                  0
                  • Pablo J. RoginaP Pablo J. Rogina

                    @nagaraj_r could you please provide the command line / options you used with Valgrind?

                    N Offline
                    N Offline
                    nagaraj_r
                    wrote on last edited by
                    #12

                    @Pablo-J-Rogina exact command used is valgrind --tool=memcheck --leak-check=full exe name*

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @nagaraj_r

                      it hasn't crashed. this time.

                      That's an important start!

                      All I know is: when I run Analyze > Valgrind Memory Analyzer from Creator I accept the default filter on the Memcheck window which is having External Errors unchecked. That removes 32 warnings about internal Qt stuff, and I don't get any false positives left. (I do unfortunately get "false negatives", in that valgrind can miss some leaks. but that's another matter.)

                      N Offline
                      N Offline
                      nagaraj_r
                      wrote on last edited by
                      #13

                      @JonB Thank you for your response. I tried to suppress the errors reported from the Qt libraries using the suppression file, although some false positive errors got reduced now, but it is still not completely resolved. If you have ever used this suppression option, please provide the details.

                      JonBJ 1 Reply Last reply
                      0
                      • N nagaraj_r

                        @JonB Thank you for your response. I tried to suppress the errors reported from the Qt libraries using the suppression file, although some false positive errors got reduced now, but it is still not completely resolved. If you have ever used this suppression option, please provide the details.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #14

                        @nagaraj_r
                        Nope, as I said, no suppression, no tailoring, vanilla out-of-the-box. It arrives with the 32 Qt/C++ library errors already filtered out from not having External Errors checked (in Creator), I changed nothing, and in that state I get no further false positives.

                        I note the leak you show has libdbus in it. I wouldn't know what a "dbus" was even if I met one. Does that indicate you are running in rather different than I am?

                        N 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @nagaraj_r
                          Nope, as I said, no suppression, no tailoring, vanilla out-of-the-box. It arrives with the 32 Qt/C++ library errors already filtered out from not having External Errors checked (in Creator), I changed nothing, and in that state I get no further false positives.

                          I note the leak you show has libdbus in it. I wouldn't know what a "dbus" was even if I met one. Does that indicate you are running in rather different than I am?

                          N Offline
                          N Offline
                          nagaraj_r
                          wrote on last edited by
                          #15

                          @JonB libdbus has been installed as part of debian distribution of Ubuntu version.

                          I have created supression file by using --gen-suppressions= all option, with this suppression file, and using --suppressions=supp filename, now the valgrind memcheck tool correctly detecting the memory leaks.

                          Thank you for your support.

                          Pablo J. RoginaP JonBJ 2 Replies Last reply
                          1
                          • N nagaraj_r

                            @JonB libdbus has been installed as part of debian distribution of Ubuntu version.

                            I have created supression file by using --gen-suppressions= all option, with this suppression file, and using --suppressions=supp filename, now the valgrind memcheck tool correctly detecting the memory leaks.

                            Thank you for your support.

                            Pablo J. RoginaP Offline
                            Pablo J. RoginaP Offline
                            Pablo J. Rogina
                            wrote on last edited by
                            #16

                            @nagaraj_r said in Valgrind Memcheck tool issue:

                            now the valgrind memcheck tool correctly detecting the memory leaks.

                            Great! Please don't forget to mark your post as solved.

                            Upvote the answer(s) that helped you solve the issue
                            Use "Topic Tools" button to mark your post as Solved
                            Add screenshots via postimage.org
                            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                            1 Reply Last reply
                            0
                            • N nagaraj_r

                              @JonB libdbus has been installed as part of debian distribution of Ubuntu version.

                              I have created supression file by using --gen-suppressions= all option, with this suppression file, and using --suppressions=supp filename, now the valgrind memcheck tool correctly detecting the memory leaks.

                              Thank you for your support.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by
                              #17

                              @nagaraj_r said in Valgrind Memcheck tool issue:

                              @JonB libdbus has been installed as part of debian distribution

                              I'm sure it has, but I no idea what it is! :)

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved