Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Valgrind Memory Leak on QThread::exec()
Forum Updated to NodeBB v4.3 + New Features

Valgrind Memory Leak on QThread::exec()

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 830 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.
  • N Offline
    N Offline
    NickJT
    wrote on last edited by
    #1

    Hello,

    I am using valgrind to detect and resolve memory leaks in our Qt C++ app.

    We are getting many duplicate reports of a memory leak that does not include any of our code on the stacktrace:

    ==5739== 38 bytes in 1 blocks are definitely lost in loss record 108 of 238
    ==5739==    at 0x402C4F8: malloc (vg_replace_malloc.c:309)
    ==5739==    by 0x62265D0: ???
    ==5739==    by 0x62245BC: ???
    ==5739==    by 0x6203CFC: ???
    ==5739==    by 0x5EF8AB8: ??? (in /opt/Qt5.9/lib/libQt5DBus.so.5.9.7)
    ==5739==    by 0x5EF97FD: ??? (in /opt/Qt5.9/lib/libQt5DBus.so.5.9.7)
    ==5739==    by 0x51D3E51: QMetaCallEvent::placeMetaCall(QObject*) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51D836C: QObject::event(QEvent*) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x4FD17B9: QThread::event(QEvent*) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51A84C3: QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51A85C1: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51AADDB: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51FE72F: QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51A5E78: QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x51A62D3: QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x4FD16FA: QThread::exec() (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x5EF5D5D: ??? (in /opt/Qt5.9/lib/libQt5DBus.so.5.9.7)
    ==5739==    by 0x4FD6791: ??? (in /opt/Qt5.9/lib/libQt5Core.so.5.9.7)
    ==5739==    by 0x54F5BBB: start_thread (in /usr/lib/libpthread-2.17.so)
    ==5739==    by 0x57520ED: clone (in /usr/lib/libc-2.17.so)
    

    This is from a release build using Qt 5.9.7 32 bit on RHEL 7.

    Here is the valgrind options:

    valgrind --child-silent-after-fork=yes --smc-check=stack --tool=memcheck --gen-suppressions=all --leak-check=full --show-leak-kinds=definite,indirect,possible --log-file=/tmp/valgrindresults_`date +%s`.txt --num-callers=35 <path to exec>
    

    There are a bunch of duplicates of the above report as well as some variations where calloc or realloc are at the top of the stack. They always mention QThread::exec and fucntions related to 'events'.

    I was wondering if maybe we are doing something wrong to cause these leaks? Or maybe these are false positives? Or known issues?

    Any ideas would be appreciated.

    Thanks,
    Nick

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      are you sure you made a debug build of your own app?

      N 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        are you sure you made a debug build of your own app?

        N Offline
        N Offline
        NickJT
        wrote on last edited by
        #3

        @JoeCFD I had been doing the valgrind scans with a debug build of my project and was getting these reports. Then on the forum I actually read that the debug build mode can introduce false positives so I tried scanning a release build. Either way it made no difference in frequency or content of these aforementioned reports.

        JonBJ JoeCFDJ 2 Replies Last reply
        0
        • N NickJT

          @JoeCFD I had been doing the valgrind scans with a debug build of my project and was getting these reports. Then on the forum I actually read that the debug build mode can introduce false positives so I tried scanning a release build. Either way it made no difference in frequency or content of these aforementioned reports.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @NickJT
          If you are to get anywhere I suspect you will need to write a minimal, standalone example exhibiting this behaviour. You can post it here for others to make sure your code is as it should be.

          1 Reply Last reply
          1
          • N NickJT

            @JoeCFD I had been doing the valgrind scans with a debug build of my project and was getting these reports. Then on the forum I actually read that the debug build mode can introduce false positives so I tried scanning a release build. Either way it made no difference in frequency or content of these aforementioned reports.

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #5

            @NickJT You are using 5.9 and 38 bytes leak can be ignored. Valgrind gives all kinds of info and a lot can be ignored. A lot of issues with the libs can not be handled. You simply live with it or upgrade your libs.

            N 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @NickJT You are using 5.9 and 38 bytes leak can be ignored. Valgrind gives all kinds of info and a lot can be ignored. A lot of issues with the libs can not be handled. You simply live with it or upgrade your libs.

              N Offline
              N Offline
              NickJT
              wrote on last edited by
              #6

              @JoeCFD Thanks that was I was thinking. Just wanted to check if there was something obvious I was doing wrong.

              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