Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108790

Crash on QFuture::cancel() with continuation and thread context

    XMLWordPrintable

Details

    • Windows
    • 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

        Activity

          People

            cnn Qt Core & Network
            menzels2 Stefan Menzel
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: