Results 1 to 4 of 4

Thread: Application leads to hang on continuously reading from QProcess stdout

  1. #1
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Application leads to hang on continuously reading from QProcess stdout

    Hi,

    I have an application built using QT-3.3.8. This is using a QProcess to
    run an utility. The utility takes input and gives output. The input and output
    data size is average, but there are too many read and writes to the QProcess.
    After execution for a long time(30 minutes or so) the application hangs.
    While debugging I found that the application is stuck in "read" system call.
    This is part of socketRead function of QT, which is called on calling
    readStdout of QProcess. I am reading from the stdout of QProcess for every 10 micro
    seconds using a thread.

    As per the documentation readStdout() is a non-blocking function. But I
    don't know what causes this to block.

    Can somebody give any clue to come out of this hang situation ?

    Thanks in advance,
    Subbarao

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Application leads to hang on continuously reading from QProcess stdout

    Are you really polling the standard output of the sub-process 100,000 times per second on the chance that there is some output? Seems you should just be waiting for readyReadStdout() to be emitted and then read (a separate thread may not be needed).

    This could be a deadlock caused by unsynchronised access from multiple threads. It could be a memory leak finally crippling the program after 30 minutes.

  3. #3
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application leads to hang on continuously reading from QProcess stdout

    Thank you for the quick reply Chris.

    Yes, there is chance of having data to read after every 10 micro seconds.
    I could use the readyReadStdout() signal, but that may not give performance like
    the thread.

    I will give a try.

    Regards,
    Subbarao

  4. #4
    Join Date
    Sep 2007
    Posts
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application leads to hang on continuously reading from QProcess stdout

    Use of readyReadStdout did not help as the thread waiting for output was timing out.
    There seems to be a deadlock because of two Mutexes in the present implementation.

    Can you please suggest a tool which I can use to detect deadlock ?

    I tried with Helgrind (part of valgrind 2.2.0). But the valgrind itself crashed due to bug in it.
    Also I cannot use latest valgrind as this does not support Helgrind.

    Thanks in advance,
    Subbarao

Similar Threads

  1. Using the Stdout reading in QProcess
    By DiegoTc in forum Newbie
    Replies: 12
    Last Post: 10th July 2011, 07:36
  2. Using the Stdout reading in QProcess
    By DiegoTc in forum Qt Programming
    Replies: 7
    Last Post: 29th December 2010, 14:34
  3. QProcess can read stderr but no stdout
    By mastupristi in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2010, 09:47
  4. read stdout with QProcess under Windows
    By jlbrd in forum Qt Programming
    Replies: 4
    Last Post: 1st September 2006, 17:29
  5. Cannot get stdout from QProcess
    By johnny_sparx in forum Qt Programming
    Replies: 11
    Last Post: 3rd March 2006, 11:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.