0

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

  • Add "Threads" and "Handles" columns in Details tab of Task Manager, see what the numbers are for your application. It's leaking and running out of something; the pool probably tries to create new threads, but fails. – Igor Tandetnik Jan 17 '21 at 20:13
  • @IgorTandetnik thanks for the hint. At least at the moment this doesn't seem to be the problem. Threads and Handles in Task Manager are at reasonable level. I will keep checking this. – Ronny Fahlberg Jan 18 '21 at 15:52
  • @IgorTandetnik I confirmed that it has nothing to do with leaking or creating to many threads. Thread and Handles counts stay reasonable when QtConcurrent::run stops working. Seemingly this happens during nighttime. The machine has some automatic maintenance during nighttime (like restarting IIS, though i don't how would compromise my application). So a guess would be that something gets corrupted during this maointenance. – Ronny Fahlberg Jan 19 '21 at 10:17

0 Answers0