I experienced a strange problem using QtConcurrent::run (Qt 5.8.9). I am using this in a long-running application (a small web server application). QtConcurrent::run is used in several locations in the application and is normally working just fine.
Recently on a certain machine (Windows 10 x64, Virtual Machine, 4 Virtual Xeon Processors, 1 Core), I keep experiencing that QtConcurrent::run stops working after a couple of hours of application execution, and the only way to get it to work again is to restart the application.
Debugging proved that QtConcurrent::run is properly executed, but the runnable/functor to be executed is never called.
QtConcurrent::run uses the global QThreadPool. After starting the application and after some QtConcurrent::run calls, there is a reasonable amount of QThreadPool threads visible in the debugger which are waiting for work like this:
[Inline Frame] Qt5Core.dll!QWaitConditionPrivate::wait(QWaitConditionEvent *) Line 118 C++
Qt5Core.dll!QWaitCondition::wait(QMutex * mutex, unsigned long time) Line 179 C++
Qt5Core.dll!QThreadPoolThread::run() Line 145 C++
Qt5Core.dll!QThreadPrivate::start(void * arg) Line 380 C++
Although I wonder why they are kept alive as the Qt doc states otherwise (QThreadPool::expiryTimeout defaults to 30s) and I don't use QtConcurrent::run that often, this seems ok to me.
But at some point, the QThreadPool threads seem to actually expire (not visible in debugger anymore), and - even worse - seem to not be restarted, when I call QtConcurrent::run again.
Has anybody also ever experienced this issue?
Thanks in advance