Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
6.0
-
None
-
ba511b2fa4782d6618a5261bbbd50f0c57266a3a (qt/qtbase/dev)
Description
Running tst_qpromise with ASan shows the following error:
================================================================= ==20131==ERROR: LeakSanitizer: detected memory leaksDirect leak of 4 byte(s) in 1 object(s) allocated from: #0 0x7f970648d448 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448) #1 0x559734874f10 in int QtPrivate::ResultStoreBase::addResult<int>(int, int const*) /media/sda/work/cmake_build_prepend_optimization/qtbase/include/QtCore/../../../../../../../home/ag/work/qt5/qtbase/src/corelib/thread/qresultstore.h:161 #2 0x55973486df47 in QFutureInterface<int>::reportResult(int const*, int) /media/sda/work/cmake_build_prepend_optimization/qtbase/include/QtCore/../../../../../../../home/ag/work/qt5/qtbase/src/corelib/thread/qfutureinterface.h:273 #3 0x559734867bc4 in QFutureInterface<int>::reportResult(int const&, int) /media/sda/work/cmake_build_prepend_optimization/qtbase/include/QtCore/../../../../../../../home/ag/work/qt5/qtbase/src/corelib/thread/qfutureinterface.h:302 #4 0x5597348613fc in void QPromise<int>::addResult<int&, void, void>(int&, int) /media/sda/work/cmake_build_prepend_optimization/qtbase/include/QtCore/../../../../../../../home/ag/work/qt5/qtbase/src/corelib/thread/qpromise.h:94 #5 0x5597347ea20a in tst_QPromise::addResult() /home/ag/work/qt5/qtbase/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp:174 #6 0x5597347f610a in tst_QPromise::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /media/sda/work/cmake_build_prepend_optimization/qtbase/tests/auto/corelib/thread/qpromise/tst_qpromise_autogen/include/tst_qpromise.moc:134 #7 0x7f9704c67c0f in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const /home/ag/work/qt5/qtbase/src/corelib/kernel/qmetaobject.cpp:2316 #8 0x7f970606df92 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/media/sda/work/cmake_build_prepend_optimization/qtbase/lib/libQt6Test.so.6+0xbdf92) #9 0x7f970605acb1 in QTest::TestMethods::invokeTestOnData(int) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:934 #10 0x7f970605cd88 in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1163 #11 0x7f9706060351 in QTest::TestMethods::invokeTests(QObject*) const /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1506 #12 0x7f9706061a30 in QTest::qRun() /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1933 #13 0x7f9706060cc4 in QTest::qExec(QObject*, int, char**) /home/ag/work/qt5/qtbase/src/testlib/qtestcase.cpp:1841 #14 0x5597347f5fc2 in main /home/ag/work/qt5/qtbase/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp:606 #15 0x7f9703e64b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
The leak sanitizer points me to the first call to QPromise::addResult(). Interestingly enough, another similar call that is done in the same test is not leaking.
Initial assumption: something bad happens when adding result by an index that is already used e.g.
promise.addResult(42);
promise.addResult(43, 0); // what happens with stored 42?