Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.8.x, 5.0.0
Description
Notice the invalid memory usage by initialize row before column.
QTestData &td = QTest::newRow("row1"); QTest::addColumn<QString>("col1"); QString str1 = "col1val"; td << str1; //invalid memory usage.
Valgrind output as below.
leonard@machine:~/Desktop/fooqstringtest-build-0e6b6d-Debug$ valgrind ./tst_fooqstringtest ==26627== Memcheck, a memory error detector ==26627== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==26627== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==26627== Command: ./tst_fooqstringtest ==26627== ********* Start testing of FooQStringTest ********* Config: Using QTest library 4.7.4, Qt 4.7.4 PASS : FooQStringTest::initTestCase() ==26627== Invalid write of size 4 ==26627== at 0x4043821: QTestData::append(int, void const*) (qtestdata.cpp:84) ==26627== by 0x8049087: QTestData& operator<< <QString>(QTestData&, QString const&) (qtestdata.h:63) ==26627== by 0x8048D68: FooQStringTest::testCase1_data() (tst_fooqstringtest.cpp:78) ==26627== by 0x8048F28: FooQStringTest::qt_metacall(QMetaObject::Call, int, void**) (tst_fooqstringtest.moc:79) ==26627== by 0x41C5E2C: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x41C790F: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x403BF88: QTest::invokeMethod(QObject*, char const*) (qmetaobject.h:101) ==26627== by 0x1C: ??? ==26627== Address 0x4646fc8 is 0 bytes after a block of size 0 alloc'd ==26627== at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==26627== by 0x4042F5C: QTestData::QTestData(char const*, QTestTable*) (qtestdata.cpp:54) ==26627== by 0x4042B7F: QTestTable::newData(char const*) (qtesttable.cpp:176) ==26627== by 0x8048F28: FooQStringTest::qt_metacall(QMetaObject::Call, int, void**) (tst_fooqstringtest.moc:79) ==26627== by 0x41C5E2C: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x41C790F: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x403BF88: QTest::invokeMethod(QObject*, char const*) (qmetaobject.h:101) ==26627== by 0x1C: ??? ==26627== PASS : FooQStringTest::testCase1() ==26627== Invalid read of size 4 ==26627== at 0x4043252: QTestData::~QTestData() (qtestdata.cpp:61) ==26627== by 0x4042932: QTestTablePrivate::~QTestTablePrivate() (qtesttable.cpp:97) ==26627== by 0x4042C41: QTestTable::~QTestTable() (qtesttable.cpp:190) ==26627== by 0x403F64E: QTest::qInvokeTestMethod(char const*, char const*) (qtestcase.cpp:1395) ==26627== by 0x403FD97: QTest::qExec(QObject*, int, char**) (qtestcase.cpp:1521) ==26627== by 0x8048DDA: main (tst_fooqstringtest.cpp:116) ==26627== Address 0x4646fc8 is 0 bytes after a block of size 0 alloc'd ==26627== at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==26627== by 0x4042F5C: QTestData::QTestData(char const*, QTestTable*) (qtestdata.cpp:54) ==26627== by 0x4042B7F: QTestTable::newData(char const*) (qtesttable.cpp:176) ==26627== by 0x8048F28: FooQStringTest::qt_metacall(QMetaObject::Call, int, void**) (tst_fooqstringtest.moc:79) ==26627== by 0x41C5E2C: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x41C790F: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x403BF88: QTest::invokeMethod(QObject*, char const*) (qmetaobject.h:101) ==26627== by 0x1C: ??? ==26627== QDEBUG : FooQStringTest::UnknownTestFunc() ======== 0 QDEBUG : FooQStringTest::UnknownTestFunc() 10 ==26627== Invalid read of size 4 ==26627== at 0x4043155: QTestData::~QTestData() (qtestdata.cpp:65) ==26627== by 0x4042932: QTestTablePrivate::~QTestTablePrivate() (qtesttable.cpp:97) ==26627== by 0x4042C41: QTestTable::~QTestTable() (qtesttable.cpp:190) ==26627== by 0x403F64E: QTest::qInvokeTestMethod(char const*, char const*) (qtestcase.cpp:1395) ==26627== by 0x403FD97: QTest::qExec(QObject*, int, char**) (qtestcase.cpp:1521) ==26627== by 0x8048DDA: main (tst_fooqstringtest.cpp:116) ==26627== Address 0x4646fc8 is 0 bytes after a block of size 0 alloc'd ==26627== at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==26627== by 0x4042F5C: QTestData::QTestData(char const*, QTestTable*) (qtestdata.cpp:54) ==26627== by 0x4042B7F: QTestTable::newData(char const*) (qtesttable.cpp:176) ==26627== by 0x8048F28: FooQStringTest::qt_metacall(QMetaObject::Call, int, void**) (tst_fooqstringtest.moc:79) ==26627== by 0x41C5E2C: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x41C790F: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x403BF88: QTest::invokeMethod(QObject*, char const*) (qmetaobject.h:101) ==26627== by 0x1C: ??? ==26627== QDEBUG : FooQStringTest::UnknownTestFunc() 0x46470c8 ==26627== Invalid read of size 4 ==26627== at 0x4043214: QTestData::~QTestData() (qtestdata.cpp:66) ==26627== by 0x4042932: QTestTablePrivate::~QTestTablePrivate() (qtesttable.cpp:97) ==26627== by 0x4042C41: QTestTable::~QTestTable() (qtesttable.cpp:190) ==26627== by 0x403F64E: QTest::qInvokeTestMethod(char const*, char const*) (qtestcase.cpp:1395) ==26627== by 0x403FD97: QTest::qExec(QObject*, int, char**) (qtestcase.cpp:1521) ==26627== by 0x8048DDA: main (tst_fooqstringtest.cpp:116) ==26627== Address 0x4646fc8 is 0 bytes after a block of size 0 alloc'd ==26627== at 0x402B454: operator new[](unsigned int) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==26627== by 0x4042F5C: QTestData::QTestData(char const*, QTestTable*) (qtestdata.cpp:54) ==26627== by 0x4042B7F: QTestTable::newData(char const*) (qtesttable.cpp:176) ==26627== by 0x8048F28: FooQStringTest::qt_metacall(QMetaObject::Call, int, void**) (tst_fooqstringtest.moc:79) ==26627== by 0x41C5E2C: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x41C790F: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /home/leonard/Downloads/qt-everywhere-commercial-src-4.7.4-build/lib/libQtCore.so.4.7.4) ==26627== by 0x403BF88: QTest::invokeMethod(QObject*, char const*) (qmetaobject.h:101) ==26627== by 0x1C: ??? ==26627== PASS : FooQStringTest::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped ********* Finished testing of FooQStringTest ********* ==26627== ==26627== HEAP SUMMARY: ==26627== in use at exit: 0 bytes in 0 blocks ==26627== total heap usage: 374 allocs, 374 frees, 104,002 bytes allocated ==26627== ==26627== All heap blocks were freed -- no leaks are possible ==26627== ==26627== For counts of detected and suppressed errors, rerun with: -v ==26627== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0) leonard@machine:~/Desktop/fooqstringtest-build-0e6b6d-Debug$