Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.0
-
None
-
855c44846 (dev), 3783c53df (6.5), de8eafc5a (6.5.2), f0765c556 (6.6), 7a471894c (tqtc/lts-6.2)
Description
The following trivial example will crash as soon the the block ends:
{ QPromise<int> p; auto f = p.future() .onFailed([] { return 42; }) .then([](int i) { qDebug() << i; }); }
Stacktrace:
Thread 1 (Thread 0x7ff1dc7b68c0 (LWP 20536)): #0 0x00007ff1df524c7f in __GI___wait4 (pid=20541, stat_loc=0x0, options=0, usage=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:27 #1 0x00007ff1dfe8c68d in generateStackTrace() () from /opt/qt6/lib/libQt6Test.so.6 #2 0x00007ff1dfe8f242 in (anonymous namespace)::FatalSignalHandler::actionHandler(int, siginfo_t*, void*) () from /opt/qt6/lib/libQt6Test.so.6 #3 <signal handler called> #4 0x000055582c6cabf6 in QtPrivate::ResultItem::isVector (this=0x28) at /opt/qt6/include/QtCore/qresultstore.h:32 #5 0x000055582c6d373e in QtPrivate::ResultIteratorBase::pointer<int> (this=0x7ffdccdde830) at /opt/qt6/include/QtCore/qresultstore.h:81 #6 0x000055582c6d2da8 in QtPrivate::ResultIteratorBase::pointer<int> (this=0x7ffdccdde830) at /opt/qt6/include/QtCore/qresultstore.h:74 #7 0x000055582c6d235a in QtPrivate::ResultIteratorBase::value<int> (this=0x7ffdccdde830) at /opt/qt6/include/QtCore/qresultstore.h:68 #8 0x000055582c6d0e84 in QFutureInterface<int>::resultReference (this=0x7ffdccdde910, index=0) at /opt/qt6/include/QtCore/qfutureinterface.h:371 #9 0x000055582c6d3404 in QFuture<int>::result<int, void> (this=0x7ffdccdde910) at /opt/qt6/include/QtCore/qfuture.h:308 #10 0x000055582c6d29da in QtPrivate::fulfillPromise<int> (promise=..., future=...) at /opt/qt6/include/QtCore/qfuture_impl.h:650 #11 0x000055582c6c1adb in QtPrivate::FailureHandler<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()>, int>::run(void) (this=0x7ffdccdde900) at /opt/qt6/include/QtCore/qfuture_impl.h:725 #12 0x000055582c6c0723 in operator() (this=0x55582d7f6880, parentData=...) at /opt/qt6/include/QtCore/qfuture_impl.h:679 #13 0x000055582c6c83e5 in QtPrivate::ContinuationWrapper<QtPrivate::FailureHandler<Function, ResultType>::create<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()> >::<lambda(const QFutureInterfaceBase&)> >::operator()(const QFutureInterfaceBase &) (this=0x55582d7f6880, parentData=...) at /opt/qt6/include/QtCore/qfuture_impl.h:502 #14 0x000055582c6c764f in std::__invoke_impl<void, QtPrivate::ContinuationWrapper<QtPrivate::FailureHandler<Function, ResultType>::create<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()> >::<lambda(const QFutureInterfaceBase&)> >&, const QFutureInterfaceBase&>(std::__invoke_other, QtPrivate::ContinuationWrapper<QtPrivate::FailureHandler<Function, ResultType>::create<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()> >::<lambda(const QFutureInterfaceBase&)> > &) (__f=...) at /usr/include/c++/10/bits/invoke.h:60 #15 0x000055582c6c65e9 in std::__invoke_r<void, QtPrivate::ContinuationWrapper<QtPrivate::FailureHandler<Function, ResultType>::create<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()> >::<lambda(const QFutureInterfaceBase&)> >&, const QFutureInterfaceBase&>(QtPrivate::ContinuationWrapper<QtPrivate::FailureHandler<Function, ResultType>::create<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()> >::<lambda(const QFutureInterfaceBase&)> > &) (__fn=...) at /usr/include/c++/10/bits/invoke.h:110 #16 0x000055582c6c4438 in std::_Function_handler<void(const QFutureInterfaceBase&), QtPrivate::ContinuationWrapper<QtPrivate::FailureHandler<Function, ResultType>::create<AsyncSupportTest::testCancelledPromiseWithOnFailed()::<lambda()> >::<lambda(const QFutureInterfaceBase&)> > >::_M_invoke(const std::_Any_data &, const QFutureInterfaceBase &) (__functor=..., __args#0=...) at /usr/include/c++/10/bits/std_function.h:291 #17 0x00007ff1dfb4729a in QFutureInterfaceBase::runContinuation() const () from /opt/qt6/lib/libQt6Core.so.6 #18 0x000055582c6ce206 in QPromise<int>::~QPromise (this=0x7ffdccddeab0, __in_chrg=<optimized out>) at /opt/qt6/include/QtCore/qpromise.h:42 #19 0x000055582c6bda32 in AsyncSupportTest::testCancelledPromiseWithOnFailed (this=0x7ffdccddf470) at /home/arehn/src/combwatch-ecosystem/dcf-core/unittests/core/asyncsupport/tst_asyncsupport.cpp:66 #20 0x000055582c6bf8ea in AsyncSupportTest::qt_static_metacall (_o=0x7ffdccddf470, _c=QMetaObject::InvokeMetaMethod, _id=2, _a=0x7ffdccddedd0) at /home/arehn/src/build-combwatch-ecosystem-Menlo_Qt6_6_5_0-Debug/dcf-core/unittests/core/asyncsupport/tst_asyncsupport_autogen/include/tst_asyncsupport.moc:303 #21 0x00007ff1df9a35a6 in QMetaMethodInvoker::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) () from /opt/qt6/lib/libQt6Core.so.6 #22 0x00007ff1df9a45c0 in QMetaMethod::invokeImpl(QMetaMethod, void*, Qt::ConnectionType, long long, void const* const*, char const* const*, QtPrivate::QMetaTypeInterface const* const*) () from /opt/qt6/lib/libQt6Core.so.6 #23 0x00007ff1dfe9578d in QTest::TestMethods::invokeTestOnData(int) const () from /opt/qt6/lib/libQt6Test.so.6 #24 0x00007ff1dfe96245 in QTest::TestMethods::invokeTest(int, QLatin1String, QTest::WatchDog*) const () from /opt/qt6/lib/libQt6Test.so.6 #25 0x00007ff1dfe96937 in QTest::TestMethods::invokeTests(QObject*) const () from /opt/qt6/lib/libQt6Test.so.6 #26 0x00007ff1dfe978a4 in QTest::qRun() () from /opt/qt6/lib/libQt6Test.so.6 #27 0x00007ff1dfe97dc0 in QTest::qExec(QObject*, int, char**) () from /opt/qt6/lib/libQt6Test.so.6 #28 0x000055582c6bf560 in main (argc=2, argv=0x7ffdccddf5a8) at /home/arehn/src/combwatch-ecosystem/dcf-core/unittests/core/asyncsupport/tst_asyncsupport.cpp:201 [Inferior 1 (process 20536) detached] === End of stack trace ===
Seems like it wants to run the failure handler, even though ~QPromise() should just run the cancellation handler (if any) and be done with it.