qt6-bb10/src/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
compat QXmlStreamWriter: port API from QString to QAnyStringView 2022-12-10 01:00:27 +01:00
doc Slow Deprecation of FILENAME_VARIABLE, replacement by OUTPUT_SCRIPT 2023-01-05 21:56:21 +01:00
global Reflect QStyleHints in AA_DontShowShortcutsInContextMenus 2023-01-04 15:49:11 +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 Docs: adjust docs after the QLatin1String to QLatin1StringView rename 2023-01-05 14:46:38 +02:00
mimetypes Use QFileInfo's file times in UTC for file timestamps 2023-01-04 19:15:52 +02:00
platform Android: requestPermissionsInternal(): use more makeReadyFuture() 2023-01-05 19:01:21 +00:00
plugin QUuid: add the ability to specify the byte order for 128-bit IDs 2022-12-16 19:29:10 +01:00
serialization Docs: adjust docs after the QLatin1String to QLatin1StringView rename 2023-01-05 14:46:38 +02:00
text Docs: adjust docs after the QLatin1String to QLatin1StringView rename 2023-01-05 14:46:38 +02:00
thread Fix crash when cancelling a QFuture that has continuation with context 2023-01-06 14:00:56 +00:00
time QDateTimeParser: use a local var instead of multiple str::at() 2023-01-04 16:49:12 +02:00
tools [doc] QSharedPointer: add some missing docs 2022-12-22 08:40:23 +01:00
CMakeLists.txt Fix moc warning for qwineventnotifier.h on non-Windows platforms 2022-12-09 16:16:49 +01:00
Qt6AndroidMacros.cmake Move '--sign' argument to the end of the androiddeployqt command 2023-01-02 14:50:51 +01:00
Qt6CTestMacros.cmake Remove cmake output about module major/minor/patch version 2023-01-03 13:53:47 +01:00
Qt6CoreConfigExtras.cmake.in Add permission API backend for macOS and iOS 2022-11-03 15:02:36 +01:00
Qt6CoreConfigureFileTemplate.in
Qt6CoreDeploySupport.cmake CMake: Avoid repeating DESTDIR when deploying Qt libs and plugins 2022-12-21 15:46:53 +01:00
Qt6CoreMacros.cmake Slow Deprecation of FILENAME_VARIABLE, replacement by OUTPUT_SCRIPT 2023-01-05 21:56:21 +01:00
Qt6WasmMacros.cmake Always export and link in JSEvents and specialHTMLTargets 2022-11-15 12:19:47 +01:00
QtCompressMimeDatabase.cmake Replace the scripting-based mime types compression mechanism with CMake 2022-12-01 02:23:51 +01:00
QtCore.dynlist
QtInstallPaths.cmake.in Move install paths from CoreConfigExtras.cmake to a separate file 2022-10-25 16:05:11 +02:00
configure.cmake Warn about WinRT only on WIN32 2022-12-04 22:11:33 +01:00
debug_script.py Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qt_cmdline.cmake Add an option to select the preferred compression type for mime type db 2022-12-01 02:23:51 +01:00
qtcore.tracepoints