Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
FutureWatcher is never finished for QtConcurent::MappedReduced as last thread is suspended
dbill last edited by
I am currently facing a strange behavior trying to use QtConcurrent::MappedReduced to dispatch some intensive work on threads.
In fact I store up to 300 input data into a QVector, call QtConcurrent::MappedReduced(unordered) to execute the same computation on these data and wait for the reduced result using QFutureWatcher.
Every thing is correct for the 299 first computations but when it comes to the last one, the thread dedicated to this computation is stuck on some method of one of my classes; and QFutureWatcher is endlessly waiting for the multithreaded computation to finish.
Depending on the run, the thread which does not terminate is not always the same (i.e. the input data is not the always the same) but there is always one thread which does not terminate at the end of concurrent computation, blocking the application forever.
I can see into the traces that the number of working threads in the QThreadPool is initially set to 8 (i.e. the ideal number of threads in the pool considering the 8 cores of the CPU) until the end of concurrent computation where this number is smoothly decreasing down to 1 (but never to 0 alas).
When I am looking into the stack of the suspended thread, I can see that this thread is trying to delete some QSharedPointer but it seems that it fails to do so as it is stuck there.
Seems to me that my problem is related to the managment of QSharedPointer in QThread.
I am using QtCreator 3.4.1 and Qt 5.5.1 which is not the mots up-to-date environment but OK it should work nevertheless.
I have asked my friend google trying to find someone who may have encounter the same kind of problem, in vain.
Does anyone have an idea about the reason why my application is stuck waiting to delete some QSharedPointer ?
Thank you for your attention.
VRonin last edited by
I see in your call stack that you are executing a method via QtConcurrent, the lifetime of the object hosting said function might be the coulprit here.
Can you tell us what is your concurrent function calling on each item in the vector?