qt5base-lts/tests/auto/corelib
Sona Kurazyan 9e61cc4f72 Fix crash when cancelling a QFuture that has continuation with context
To support cancellation of continuations attached via the parent future,
we store a pointer to continuation future's data in parent. This
requires preserving the lifetime of continuation future's data while the
parent is still alive (see 24dedaeaa1).
This is achieved by capturing the promise in the continuation's lambda,
which is only cleaned up after the parent's data is destroyed. This is
already the case for continuations without context, but was overlooked
for continuations with context: they transfer the ownership of the
continuation promise to lambda passed to QMetaObject::invokeMethod(),
which destroys the lambda's context after it's run. As a result, the
continuation's promise (and data, if there are no other copies of it)
is also destroyed, leaving the parent pointing to deleted continuation
data.

To fix this, capture a copy of continuation future's ref-counted data in
the continuation's lambda. This will guarantee that the continuation
data remains alive until the parent is destroyed and the continuation
is cleaned up.

Fixes: QTBUG-108790
Pick-to: 6.5 6.4 6.2
Change-Id: Ief4b37f31e652988d13b03499505ac65c7889226
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-06 14:00:56 +00:00
..
animation Port from container::count() and length() to size() - V5 2022-11-03 14:59:24 +01:00
global QTypeInfo: remove further usages of isPointer / isIntegral 2022-12-30 01:51:27 +01:00
io Use QFileInfo's file times in UTC for file timestamps 2023-01-04 19:15:52 +02:00
itemmodels Port from container::count() and length() to size() - V5 2022-11-03 14:59:24 +01:00
kernel QMetaType: fix value-initialization in a corner case 2022-12-30 01:51:08 +01:00
mimetypes Use QFileInfo's file times in UTC for file timestamps 2023-01-04 19:15:52 +02:00
platform CMake: Remove direct qt_android_generate_deployment_settings call 2022-12-15 20:23:28 +01:00
plugin QUuid: add the ability to specify the byte order for 128-bit IDs 2022-12-16 19:29:10 +01:00
serialization QXmlStreamWriter: fix a thinko in doWriteToDevice(QSV) 2022-12-16 22:58:11 +01:00
text Accept U+2212 as minus sign in negative year unit test 2023-01-06 14:51:05 +01:00
thread Fix crash when cancelling a QFuture that has continuation with context 2023-01-06 14:00:56 +00:00
time Deprecate QDateTime methods using plain Qt::TimeSpec 2022-12-10 06:39:33 +01:00
tools QTypeInfo: remove further usages of isPointer / isIntegral 2022-12-30 01:51:27 +01:00
CMakeLists.txt Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00