Valgrind Warnings

Discuss anything related to product development
Post Reply
seasoned_geek
Posts: 246
Joined: Thu Jun 11 2020 12:18 pm

Valgrind Warnings

Post by seasoned_geek »

Just some things I stumbled on while running valgrind on a fork of Diamond.

These appear to be leaks inside of CopperSpice in various places.

These aren't all from the same valgrind run. They could be some normal valgrind confusion.

It appears QTextDocumentLayout has a small memory leak

Code: Select all

==59076== 4 bytes in 1 blocks are definitely lost in loss record 135 of 4,732
==59076==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==59076==    by 0x87E750E: strdup (strdup.c:42)
==59076==    by 0x7E985CF: QMetaObject::getSignatures(QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x55D36A0: void QMetaObject_T<QAbstractTextDocumentLayout>::register_method<int (QAbstractTextDocumentLayout::*)()>(QString8 const&, int (QAbstractTextDocumentLayout::*)(), QMetaMethod::MethodTy$
==59076==    by 0x55D4685: QAbstractTextDocumentLayout::cs_regTrigger(cs_number<0>) [clone .isra.0] (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x55D4A6D: QAbstractTextDocumentLayout::staticMetaObject() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x7E94BF7: QMetaObject_X::methodCount() const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E96B00: QMetaObject::indexOfMethod(QString8 const&) const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7EAD945: QObject::connect(QObject const*, QString8 const&, QObject const*, QString8 const&, Qt::ConnectionType, QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x63BF25B: QAbstractTextDocumentLayout::registerHandler(int, QObject*) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x63C21EA: QTextDocumentLayout::QTextDocumentLayout(QTextDocument*) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x63849CA: QTextDocument::documentLayout() const (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
leak in QPlainTextDocumentLayout logic path

Code: Select all

==67948== 720 bytes in 30 blocks are definitely lost in loss record 4,640 of 4,731
==67948==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==67948==    by 0x54280FA: CsSignal::Internal::Bento<void (QAbstractScrollArea::*)()>::clone() const (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==67948==    by 0x55406B7: void CsSignal::activate<QAbstractSlider, QAbstractSlider, int, int, int&, int&>(QAbstractSlider&, void (QAbstractSlider::*)(int, int), int&, int&) (in /home/roland/Projects/diamond_de$
==67948==    by 0x65EBDC8: QAbstractSlider::setRange(int, int) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==67948==    by 0x6835195: QPlainTextEditPrivate::_q_adjustScrollbars() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==67948==    by 0x1F5F1F: void CsSignal::Internal::cs_unpack_method_args_internal<QPlainTextEdit, void>(QPlainTextEdit*, void (QPlainTextEdit::*)(), std::tuple<> const&, std::integer_sequence<unsigned long>) (c$
==67948==    by 0x1F55B2: CsSignal::Internal::CSVoidReturn CsSignal::Internal::cs_unpack_method_args<QPlainTextEdit>(QPlainTextEdit*, void (QPlainTextEdit::*)(), std::tuple<> const&) (cs_internal.h:174)
==67948==    by 0x1F49A5: CsSignal::Internal::Bento<void (QPlainTextEdit::*)()>::invoke(CsSignal::SlotBase*, CsSignal::Internal::TeaCupAbstract const*) const (cs_internal.h:646)
==67948==    by 0x555AD28: void CsSignal::activate<QTextControl, QTextControl, QSizeF const&, QSizeF const&>(QTextControl&, void (QTextControl::*)(QSizeF const&), QSizeF const&) (in /home/roland/Projects/diamon$
==67948==    by 0x54F973E: CsSignal::Internal::Bento<void (QTextControl::*)(QSizeF const&)>::invoke(CsSignal::SlotBase*, CsSignal::Internal::TeaCupAbstract const*) const (in /home/roland/Projects/diamond_debug/$
==67948==    by 0x5539D38: void CsSignal::activate<QAbstractTextDocumentLayout, QAbstractTextDocumentLayout, QSizeF const&, QSizeF const&>(QAbstractTextDocumentLayout&, void (QAbstractTextDocumentLayout::*)(QSi$
==67948==    by 0x6830755: QPlainTextDocumentLayout::layoutBlock(QTextBlock const&) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==67948==    
As does this QFactoryLoader path

Code: Select all

==59076== 5 bytes in 1 blocks are definitely lost in loss record 290 of 4,732
==59076==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==59076==    by 0x87E750E: strdup (strdup.c:42)
==59076==    by 0x7E985CF: QMetaObject::getSignatures(QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E9C01D: QMetaObject_X::register_method_s1(QString8 const&, QMetaMethod::Access, QMetaMethod::MethodType) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7CBC139: QObject::cs_regTrigger(cs_number<2>) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7CBCA35: QObject::staticMetaObject() (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E950DB: QMetaObject::indexOfClassInfo(QString8 const&) const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7F1D444: QLibraryHandle::updatePluginState() (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7F1D9F0: QLibraryHandle::isPlugin() (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7F124DE: QFactoryLoader::setup() (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7F14A51: QFactoryLoader::QFactoryLoader(QString8 const&, QString8 const&, Qt::CaseSensitivity) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x61341EB: loader() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    
QXcbIntegration has a little one

Code: Select all

==59076== 5 bytes in 1 blocks are definitely lost in loss record 296 of 4,732
==59076==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==59076==    by 0x87E750E: strdup (strdup.c:42)
==59076==    by 0x7E985CF: QMetaObject::getSignatures(QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E9C01D: QMetaObject_X::register_method_s1(QString8 const&, QMetaMethod::Access, QMetaMethod::MethodType) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7CC07AA: QThread::staticMetaObject() (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E94BF7: QMetaObject_X::methodCount() const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E968F9: QMetaObject::indexOfSignal(QString8 const&) const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7EAD927: QObject::connect(QObject const*, QString8 const&, QObject const*, QString8 const&, Qt::ConnectionType, QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x962A481: QXcbEventReader::start() (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==59076==    by 0x962F1A0: QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==59076==    by 0x964FF63: QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==59076==    by 0x84C7BA5: QXcbIntegrationPlugin::create(QString8 const&, QStringList const&, int&, char**) (in /home/roland/Projects/diamond_debug/platforms/CsGuiXcb1.7.so)
==59076==
==59076== 5 bytes in 1 blocks are definitely lost in loss record 297 of 4,732
==59076==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==59076==    by 0x87E750E: strdup (strdup.c:42)
==59076==    by 0x7E985CF: QMetaObject::getSignatures(QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E9C01D: QMetaObject_X::register_method_s1(QString8 const&, QMetaMethod::Access, QMetaMethod::MethodType) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7CC082B: QThread::staticMetaObject() (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E94BF7: QMetaObject_X::methodCount() const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E968F9: QMetaObject::indexOfSignal(QString8 const&) const (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7EAD927: QObject::connect(QObject const*, QString8 const&, QObject const*, QString8 const&, Qt::ConnectionType, QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x962A481: QXcbEventReader::start() (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==59076==    by 0x962F1A0: QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==59076==    by 0x964FF63: QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==59076==    by 0x84C7BA5: QXcbIntegrationPlugin::create(QString8 const&, QStringList const&, int&, char**) (in /home/roland/Projects/diamond_debug/platforms/CsGuiXcb1.7.so)
this cs_typeToName tiny leak

Code: Select all

==59076== 5 bytes in 1 blocks are definitely lost in loss record 307 of 4,732
==59076==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==59076==    by 0x87E750E: strdup (strdup.c:42)
==59076==    by 0x7E985CF: QMetaObject::getSignatures(QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x7E9C01D: QMetaObject_X::register_method_s1(QString8 const&, QMetaMethod::Access, QMetaMethod::MethodType) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x53CF809: QScreen::cs_regTrigger(cs_number<44>) [clone .isra.0] (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CCBC5: QScreen::cs_regTrigger(cs_number<38>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CCFC2: QScreen::cs_regTrigger(cs_number<30>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CD552: QScreen::cs_regTrigger(cs_number<20>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CDA25: QScreen::cs_regTrigger(cs_number<14>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CDEE4: QScreen::cs_regTrigger(cs_number<6>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CE5D7: QScreen::staticMetaObject() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53CE6D0: QString8 const& cs_typeToName<QScreen*>() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
Just a hunch, but I believe it is in the lower level routines because they seem to be common for quite a few 5 byte leaks

Code: Select all

==59076== 5 bytes in 1 blocks are definitely lost in loss record 328 of 4,732
==59076==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==59076==    by 0x87E750E: strdup (strdup.c:42)
==59076==    by 0x7E985CF: QMetaObject::getSignatures(QString8 const&) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==59076==    by 0x53C45ED: void QMetaObject_T<QApplication>::register_method<void (QApplication::*)(bool)>(QString8 const&, void (QApplication::*)(bool), QMetaMethod::MethodType, QString8 const&, QMetaMethod::A$
==59076==    by 0x53D4DC7: QApplication::cs_regTrigger(cs_number<50>) [clone .isra.0] (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53D53B8: QApplication::cs_regTrigger(cs_number<42>) [clone .isra.0] (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53D5825: QApplication::cs_regTrigger(cs_number<32>) [clone .isra.0] (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53D5C95: QApplication::cs_regTrigger(cs_number<25>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53D631E: QApplication::cs_regTrigger(cs_number<15>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53D324D: QApplication::cs_regTrigger(cs_number<4>) (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x53D389A: QApplication::staticMetaObject() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)
==59076==    by 0x5D8349A: qt_detectRTLLanguage() (in /home/roland/Projects/diamond_debug/libCsGui1.7.so)

Xcb code path appears to be leaky

Code: Select all

==67948== 48,352 bytes in 1,511 blocks are definitely lost in loss record 4,730 of 4,731
==67948==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==67948==    by 0x961222E: CSBento<void (QXcbConnection::*)()>::clone() const (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==67948==    by 0x961524C: void CsSignal::activate<QXcbEventReader, QXcbEventReader>(QXcbEventReader&, void (QXcbEventReader::*)()) (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==67948==    by 0x962A2AE: QXcbEventReader::run() (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==67948==    by 0x7FCC64A: QThreadPrivate::start(void*) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==67948==    by 0x8940608: start_thread (pthread_create.c:477)
==67948==    by 0x8867292: clone (clone.S:95)
==67948==

==69043== 45,120 bytes in 1,410 blocks are definitely lost in loss record 4,742 of 4,743
==69043==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==69043==    by 0x961222E: CSBento<void (QXcbConnection::*)()>::clone() const (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==69043==    by 0x961524C: void CsSignal::activate<QXcbEventReader, QXcbEventReader>(QXcbEventReader&, void (QXcbEventReader::*)()) (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==69043==    by 0x962A2AE: QXcbEventReader::run() (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==69043==    by 0x7FCC64A: QThreadPrivate::start(void*) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==69043==    by 0x8940608: start_thread (pthread_create.c:477)
==69043==    by 0x8867292: clone (clone.S:95)
==69043==

Code: Select all

==70287== 96 bytes in 3 blocks are definitely lost in loss record 3,491 of 4,733
==70287==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==70287==    by 0x97330C5: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==70287==    by 0x9730E9E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==70287==    by 0x9732909: xcb_wait_for_event (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==70287==    by 0x962A21B: QXcbEventReader::run() (in /home/roland/Projects/diamond_debug/libCsXcbSupport1.7.so)
==70287==    by 0x7FCC64A: QThreadPrivate::start(void*) (in /home/roland/Projects/diamond_debug/libCsCore1.7.so)
==70287==    by 0x8940608: start_thread (pthread_create.c:477)
==70287==    by 0x8867292: clone (clone.S:95)
==70287==
Post Reply