Qt 6.8.3 with BlackBerry 10 (QNX 8 / ARMv7) patches
 
 
 
 
 
 
Go to file
Ivan Solovev 2395d5d8d1 QFuture: prevent the continuations from being executed twice
On some very rare cases the continuation could be executed twice in a
multithreaded scenario. Consider the following example:

  auto f = QtConcurrent::run(someFunction);
  f.then(someOtherFunction);

Assuming that QtConcurrent::run() is executed on Thread B, and the
continuation is attached in Thread A, the following call stack is
possible:
1. Thread B: someFunction() is finished
2. Thread B: QFutureInterface::reportFinished() is called
3. Thread B: QFutureInterfaceBase::reportFinished() is called and
             finished.
4. Thread A: then() is called. It checks that the future is already
             finished, so the attached continuation is executed
             immediately.
5. Thread B: QFutureInterfaceBase::runContinuation() is executed.
             At this point it sees that a continuation exists, and
             executes it again.

Step 5 will lead to a crash, because we'll try to access a moved-from
QPromise.

To fix the issue, introduce a flag that is explicitly used to test if
the continuation was already executed or not.

The pre-existing code already uses a concept of a continuation state,
but it cannot be easily extended without convering it from an enum
to flags, because the canceled continuation should still be called
in order to actually execute the onCanceled() handler.

Wrapping QFIBP::ContinuationState into QFlags would increase its size
from 1 to 4 bytes, and manually treating the enum as flags will result
in a more complicated code. So, I simply picked the approach of adding
an explicit flag for this case.

Writing a unit-test is not really possible, but I verified that the
reproducer from the linked Jira ticket does not crash anymore.

Amends dfaca09e85 that introduced the
continuations, so picking to all active Qt 6 branches.

Fixes: QTBUG-118032
Pick-to: 6.5
Change-Id: I3e07722495e38367e8e4be2eded34140e22b0053
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 04b5d2b94f96c73a13973f6a57cefbf07d2e850b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5b55e8d1f066945dc36deda6285aebc3fd315e00)
2025-02-12 12:44:15 +00:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
LICENSES Adapt license tag to follow qt_attribution.json 2025-02-03 18:07:25 +01:00
bin CMake: Don't hard-code "libexec" in qt-configure-module 2024-08-20 13:50:32 +02:00
cmake CMake: doctools: Avoid blocking integrations due to version mismatch 2025-02-12 09:23:45 +00:00
coin Add calling license check on generated source SBOM 2025-02-03 18:07:34 +01:00
config.tests QThread/Unix: refactor to split QThreadPrivate::finish() in two phases 2024-11-07 15:00:11 -07:00
dist Add REUSE.toml files 2024-11-07 08:38:49 +01:00
doc Fix or remove broken and outdated external links in qtbase documentation 2025-02-12 12:44:15 +00:00
examples Doc: Update \externalpage entries for Qt Creator documentation 2025-02-08 13:53:15 +00:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec Android: add option to run app detached to runner script 2024-12-04 14:44:52 +00:00
mkspecs Remove unsupported linker script objc_namespace.sh 2025-01-21 10:44:47 +00:00
qmake qmake: Find Apple ID via IDEProvisioningTeamByIdentifier for Xcode 16.2 2025-02-10 17:52:26 +00:00
src QFuture: prevent the continuations from being executed twice 2025-02-12 12:44:15 +00:00
tests QMenu: improve test for "empty menu" to be style-independent 2025-02-12 12:44:15 +00:00
util Unicode tool: use unsigned values for the bitfields 2025-02-10 15:33:50 +00:00
.cmake.conf Bump version to 6.8.3 2025-01-23 11:04:42 +00:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Git ignore Visual Studio CMake build directories 2023-11-24 23:42:05 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag
CMakeLists.txt cmake: add _extra_files IDE target from heuristics 2024-04-12 08:36:01 +08:00
REUSE.toml macOS: Enable crash reporting for tests via Swift 2025-01-13 08:36:30 +00:00
config_help.txt CMake: Change SBOM generation to be enabled by default (mostly) 2024-10-21 08:37:20 +00:00
configure Change configure license 2024-02-02 15:23:02 +00:00
configure.bat configure.bat: Use call when calling the helper cmake scripts 2025-01-31 14:16:17 +00:00
configure.cmake CMake: Report success for 'separate_debug_info' where applicable 2024-11-02 16:25:06 +00:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
licenseRule.json Adapt license tag to follow qt_attribution.json 2025-02-03 18:07:25 +01:00
qt_cmdline.cmake configure: accept -c++std c++17 again 2024-06-13 20:40:06 +00:00