Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
6.6.0
-
None
-
59e21a536 (dev), f89d80c90 (6.7), d5528cdec (6.6)
Description
QFuture::then(context, ...) (and probably the other continuation attachers) can deadlock in Qt 6.6.0. Example:
#include <QCoreApplication> #include <QFuture> #include <QPromise> #include <QtDebug> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QPromise<int> p; auto f = p.future(); f.then(&app, [](int i) { qDebug() << i; }); QMetaObject::invokeMethod(&app, [&] { app.quit(); }, Qt::QueuedConnection); p.start(); p.addResult(42); p.finish(); // Deadlocks. Remove to have the app quit. return app.exec(); }
I've tracked the cause to QFutureInterfaceBase::reportFinished(), which sends a QFutureCallOut without unlocking the mutex. The responders to this will want to access the future's result, which again tries to lock the mutex -> deadlock.
This happens only if the context object lives in the same thread that calls QPromise::finish().
Attachments
Issue Links
- duplicates
-
QTBUG-119579 [Reg 6.5 -> 6.6] Calling QPromise::finish() from the same thread deadlocks i
- Closed
- is duplicated by
-
QTBUG-117918 Debug builds with QFuture::waitForFinished and same-thread continuations may deadlock
- Closed
-
QTBUG-119103 QFuture hangs when continuation uses a context object and is resolved from the same thread
- Closed
For Gerrit Dashboard: QTBUG-119406 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
520860,15 | QFuture: Don't use QFutureCallOutInterface for continuations | dev | qt/qtbase | Status: MERGED | +2 | 0 |
525172,2 | QFuture: Don't use QFutureCallOutInterface for continuations | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
525292,2 | QFuture: Don't use QFutureCallOutInterface for continuations | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |