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

QPromise::finish deadlocks after matching QFuture::waitForFinished

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P1: Critical
    • None
    • 6.4.3, 6.6.2
    • Core: QtConcurrent
    • None
    • Linux/Other display system

    Description

      Creating a QPromise and fulfilling it in a separate thread, could result in a deadlock from the main thread. This can happen, because the continuation of the associated QFuture is run after signaling the finish state. If the QFuture exits scope and is deallocated, the QFutureInterfaceBase::runContinuation() call would read from a dangling mutex, potentially locking indefinitely.

      The behavior is replicatable with Qt 6.6.2 and 6.4.3 under Debian 11 (Linux 5.10.0-26-amd64) and Debian 12 (Linux 6.1.0-18-amd64).

      Attached is a small example project, replicating the bug. The program should continue printing the current timestamp, otherwise a deadlock occurred. On average, it takes less than a minute to replicate the issue.

      Attachments

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

        Activity

          People

            manordheim MÃ¥rten Nordheim
            d.walawicz Dennis Walawicz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes