Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.6.1
-
None
-
Windows 11, 64-bit, 23H2, build 22631.2792
Visual Studio 2022 , 64-bit, version 17.7.7
-
-
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.