Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
5.3.2
-
None
-
Ubuntu 16.04
Description
It appears that QFile leaks based on this valgrind report that I have.
1 ==4001== 1,419 (280 direct, 1,139 indirect) bytes in 1 blocks are definitely lost in loss record 23,847 of 25,138 2 ==4001== at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 3 ==4001== by 0x7857262: QFile::QFile(QString const&) (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Core.so.5.3.2) 4 ==4001== by 0x43DD10: CEventLog::logEvent(CEventLog::EVENT_TYPE, QString, int, int) (CEventLog.cpp:180) 5 ==4001== by 0x5F816A: CEventLog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (moc_CEventLog.cpp:113) 6 ==4001== by 0x79699B5: QObject::event(QEvent*) (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Core.so.5.3.2) 7 ==4001== by 0x62A0723: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Widgets.so.5.3.2) 8 ==4001== by 0x62A3D45: QApplication::notify(QObject*, QEvent*) (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Widgets.so.5.3.2) 9 ==4001== by 0x7935FC3: QCoreApplication::notifyInternal(QObject*, QEvent*) (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Core.so.5.3.2) 10 ==4001== by 0x7938B47: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Core.so.5.3.2) 11 ==4001== by 0x7990252: ??? (in /Tools/Qt/5.3.2/5.3/gcc_64/lib/libQt5Core.so.5.3.2) 12 ==4001== by 0x93801A6: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1) 13 ==4001== by 0x93803FF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.1) 14 ==4001==
I believe this affects all of Qt 5 (5.0 to 5.9) but have confirmation on 5.3.2.
/*! Constructs a new file object to represent the file with the given \a name. */ QFile::QFile(const QString &name) : QFileDevice(*new QFilePrivate, 0) { Q_D(QFile); d->fileName = name; }
Unless I'm missing some "magic", it appears that QFileDevice is taking a dereferenced pointer to QFilePrivate allocated on the heap (which it then takes as a reference). It does not appear as though QFileDevice attempts to free the QFilePrivate pointer, it just passes it to QIODevice which passes it to QObject as a parent.
Perhaps I'm missing something involving how QObject treats the parent when its destructor is called?
Thanks!