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

QtConcurrent task assigned to a threadpool may be executed outside the pool

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 6.3.2
    • Core: QtConcurrent
    • None
    • Arch Linux
    • Linux/Wayland
    • Foundation PM Staging

    Description

      Starting a QtConcurrent::task in a custom threadpool like depicted in the docks, results in a QFuture whose task may in fact be executed in a thread that's not part of the pool. This is really unexpected behavior.

      Apparently the reason lies in calling stealAndRunRunnable in qfutureinterface.cpp around line 400. The task is then executed in the thread that has the QFuture, and any thread specific assertions will fail.

      I noticed the issue when I started randomly getting errors like this one from Qt's SQL driver:

      QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
      

      Here's a related issue from StackOverflow: https://stackoverflow.com/questions/28332199/how-does-qtconcurrentrun-wind-up-on-main-thread

      Attachments

        Issue Links

          Activity

            People

              mmutz Marc Mutz
              iizuki Iisakki Jaakkola
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: