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

On certain machines QtConcurrent crashes if no free threads on thread pool

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.2.12, 6.5.5, 6.6.2, 6.7.0 Beta2, 6.8.0 FF
    • 6.6.1
    • Core: QtConcurrent
    • None
    • Windows 11, 64-bit, 23H2, build 22631.2792
      Visual Studio 2022 , 64-bit, version 17.7.7
    • Windows
    • 1
    • 936e72d18 (dev), 41a605e0f (6.7), e63224138 (6.6), ac5016047 (tqtc/lts-6.5), 0af71d557 (tqtc/lts-6.2)
    • Foundations Sprint 98

    Description

      Class BlockSizeManager (qtbase\src\concurrent\qtconcurrentiteratekernel.h) has the following expression in its constructor:

      BlockSizeManager::BlockSizeManager(QThreadPool *pool, int iterationCount)
          : maxBlockSize(iterationCount / (pool->maxThreadCount() * 2)),
            beforeUser(0), afterUser(0),
            m_blockSize(1)
      { }

      When pool->maxThreadCount() is zero, the division by zero exception thrown and program crashes.
      function maxThreadCount implemented as following :

      int QThreadPool::maxThreadCount() const
      {
          Q_D(const QThreadPool);
          QMutexLocker locker(&d->mutex);
          return d->requestedMaxThreadCount;
      }
      It returns a variable, not a PIMPL function
      Private implementation looks like this : ( qtbase\src\corelib\thread\qthreadpool_p.h )

       int maxThreadCount() const
          { return qMax(requestedMaxThreadCount, 1); }    // documentation says we start at least one

      That means, the public function QThreadPool::maxThreadCount()  should return a result of private function  return d->maxThreadCount() and not a private variable.

      On certain machines with limited number of CPU requestedMaxThreadCount can be zero and this leads to crash.

      Attachments

        For Gerrit Dashboard: QTBUG-120335
        # Subject Branch Project Status CR V

        Activity

          People

            ivan.solovev Ivan Solovev
            b-epelbaum Korneliy Epelbaum
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes