Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Deadlock with BlockingQueuedConnection on Exit
QtWS25 Last Chance

Deadlock with BlockingQueuedConnection on Exit

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bobthebuilder
    wrote on last edited by
    #1

    I'm running into (occasional) deadlocks in a QWidget program that uses a BlockingQueuedConnection. There is a slow worker task on a side thread that communicates to the main thread through a signal/slot created with BlockingQueuedConnection. The application also, importantly, has a measurably slow shut down time (it has to write a large amount of data to disk) and a call to quit and wait on the worker thread on exit in a widget's destructor. The deadlock occurs if the worker thread is running when the user exits the program, and the worker subsequently completes and signals the BlockingQueuedConnection before the main thread calls quit and wait. This is because the main thread will not process the BlockingQueuedConnection slot received during the widget's destruction.

    I've tried working around this by calling disconnect() on the worker at the start of the Widget's destruction, but it seems like a deadlock could still occur if the worker signals in the brief time before disconnect() is called during destruction.

    Is there a better solution to this problem? Is there a way to signal the worker to quit waiting on the BlockingQueuedConnection? Thank you!

    JonBJ 1 Reply Last reply
    0
    • B bobthebuilder

      I'm running into (occasional) deadlocks in a QWidget program that uses a BlockingQueuedConnection. There is a slow worker task on a side thread that communicates to the main thread through a signal/slot created with BlockingQueuedConnection. The application also, importantly, has a measurably slow shut down time (it has to write a large amount of data to disk) and a call to quit and wait on the worker thread on exit in a widget's destructor. The deadlock occurs if the worker thread is running when the user exits the program, and the worker subsequently completes and signals the BlockingQueuedConnection before the main thread calls quit and wait. This is because the main thread will not process the BlockingQueuedConnection slot received during the widget's destruction.

      I've tried working around this by calling disconnect() on the worker at the start of the Widget's destruction, but it seems like a deadlock could still occur if the worker signals in the brief time before disconnect() is called during destruction.

      Is there a better solution to this problem? Is there a way to signal the worker to quit waiting on the BlockingQueuedConnection? Thank you!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @bobthebuilder
      I'm afraid this is way beyond my pay grade, but does https://stackoverflow.com/questions/16741432/qt-signal-slot-multithreading-deadlocks and the proposed answer there shed any useful light on your situation?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Can you explain the need of BlockingQueuedConnection in your case ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved