Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.4.1
-
None
-
-
9e61cc4f7 (dev), a11a2ac13 (6.5), 5fed09633 (6.4), 34ac00a07 (tqtc/lts-6.2)
Description
Canceling a future that has a continuation attached that will be run in a different thread, causes a crash because some data in the continuation is not threre anymore.
saving the future of the continuation into a local variable fixes the issue.
this seemed to work fine with Qt 6.3
see this example.
#include <QCoreApplication> #include <QtConcurrent/QtConcurrent> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); auto future = QtConcurrent::run( []{}); // if the future of the continuation // is kept alive by storing into a // local variable, the cancel later works fine /*auto cont_future =*/ future.then(&a, [](){}); future.waitForFinished(); QEventLoop().processEvents(); future.cancel(); // crash here. return 0; }
Attachments
For Gerrit Dashboard: QTBUG-108790 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
450723,3 | Fix crash when cancelling a QFuture that has continuation with context | dev | qt/qtbase | Status: MERGED | +2 | 0 |
452445,2 | Fix crash when cancelling a QFuture that has continuation with context | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
452446,2 | Fix crash when cancelling a QFuture that has continuation with context | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 |
452447,2 | Fix crash when cancelling a QFuture that has continuation with context | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |