Valgrind Memory Leak on QThread::exec()
-
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 -
@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.
-
@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.
-
@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.
-
@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.