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

Deadlock QImage::scaled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P1: Critical
    • None
    • 6.5.3, 6.6.1
    • GUI: Painting
    • None
    • Windows

    Description

      Qimage::scaled never returns, because semaphore.acquire blocks in Qt code:

      template<typename T>
      static inline void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection)
      {
      #if QT_CONFIG(thread) && !defined(Q_OS_WASM)
          int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16);
          segments = std::min(segments, dh);
          QThreadPool *threadPool = QThreadPoolPrivate::qtGuiInstance();
          if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
              QSemaphore semaphore;
              int y = 0;
              for (int i = 0; i < segments; ++i) {
                  int yn = (dh - y) / (segments - i);
                  threadPool->start([&, y, yn]() {
                      scaleSection(y, y + yn);
                      semaphore.release(1);
                  });
                  y += yn;
              }
              semaphore.acquire(segments);
              return;
          }
      #endif
          scaleSection(0, dh);
      } 

      I debugged Qt code and it seems semaphore.acquire(segments); blocks. It seems all worker threads are destroyed.

      This behavior does not always occur. There may be resource problems if scaleSelection is executed in parallel. The working threads seem to run into the tiemout (expiryTimeout). Is semaphore.release(1); possibly not executed in this case?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            blgis Bernd Lachner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes