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

QFileSystemWatcher with dnotify backend hangs on app exit

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 4.7.0
    • None
    • RHEL4 (x86_64)

    Description

      I'm currently testing Qt-4.7.0-beta1/X11 release on RHEL4 (x86_64) with our software and found the following behavior change:

      QApplication::setQuitOnLastWindowClosed(true)

      no longer works reliably: it depends e.g. if a file-open dialog was executed before or not.
      The following code should demonstrate the problem clearly:

      // reproduce a behavior change (bug?) with Qt 4.7.0-beta1 (May 6 2010): 
      // The application no longer closes once file-open dialog was executed. 
      // 
      #include <QtGui/QApplication> 
      #include <QtGui/QLabel> 
      #include <QtGui> 
      
      
      int main(int argc, char* argv[]) 
      { 
          QApplication app(argc, argv);
          QLabel label; 
          label.setText("Closing this window used to return from the main loop"); 
          label.show(); 
          app.setQuitOnLastWindowClosed(true); 
          QFileDialog::getOpenFileName(&label); // remove this line to hide the problem 
          return app.exec(); 
      } 
      

      If you compile and run above code with aforementioned Qt release, you'll see that the application no longer closes after the last window is closed, but it does, however, if you remove the line with getOpenFileName.

      Configurations tested:
      ./configure -platform linux-g++-64 -prefix /usr/local/qt-4.7.0/static -release -static -exceptions -no-accessibility -no-qt3support -nomake examples -nomake demos -nomake docs -fast -silent

      and

      ./configure -platform linux-g++-64 -prefix /usr/local/qt-4.7.0/shared -release -shared -exceptions -no-accessibility -no-qt3support -nomake examples -nomake demos -nomake docs -fast -silent

      The bug happens with both configurations

      Further Information:

      Same "hang-at-exit" is happening if I simply start the designer, choose file->open from the main menu, and close the designer.
      I'm getting valuable hints from the debugger: when I start the designer from gdb I'm seeing that several threads are created and finished during execution of designer....

      user@host:~> gdb /usr/local/qt-4.7.0/shared/bin/designer
      GNU gdb 6.8 [...]
      This GDB was configured as "x86_64-unknown-linux-gnu"...
      (gdb) run
      Starting program: /usr/local/qt-4.7.0/shared/bin/designer
      [Thread debugging using libthread_db enabled]
      [New Thread 0x2a97c98080 (LWP 6153)]
      [New Thread 0x40a00960 (LWP 6157)]
      [New Thread 0x41401960 (LWP 6158)]

      Above is the output after designer has started. Now I click on file-open and I'm seeing that 2 new threads are created:

      [New Thread 0x41e02960 (LWP 6159)]
      [New Thread 0x42803960 (LWP 6160)]

      I close the file-open dialog and I can see that only one LWP has exited. LWP 6160 is still running :

      [Thread 0x41e02960 (LWP 6159) exited]

      Now I close the application and I get no further output in gdb terminal. So I'm interrupting the application (Ctrl+C) in the debugger to see the stack-trace:

      Program received signal SIGINT, Interrupt.
      [Switching to Thread 0x2a97c98080 (LWP 6153)]
      0x0000003e880089ba in pthread_cond_wait@@GLIBC_2.3.2 ()
      from /lib64/tls/libpthread.so.0
      (gdb) bt 8
      #0 0x0000003e880089ba in pthread_cond_wait@@GLIBC_2.3.2 ()
      from /lib64/tls/libpthread.so.0
      #1 0x0000002a979345ce in QWaitCondition::wait (this=0x620990, mutex=0x620970,
      time=18446744073709551615) at thread/qwaitcondition_unix.cpp:87
      #2 0x0000002a979336e0 in QThread::wait (this=<value optimized out>,
      time=18446744073709551615)
      at ../../include/QtCore/../../src/corelib/thread/qmutex.h:132
      #3 0x0000002a97a0eb47 in ~QDnotifySignalThread (this=0x5dfec0)
      at io/qfilesystemwatcher_dnotify.cpp:145
      #4 0x0000002a97a0f159 in __tcf_0 ()
      at ../../include/QtCore/../../src/corelib/thread/qbasicatomic.h:168
      #5 0x0000003e87330c45 in exit () from /lib64/tls/libc.so.6
      #6 0x0000003e8731c402 in __libc_start_main () from /lib64/tls/libc.so.6
      #7 0x000000000041910a in _start ()

      So there seems to be a QWaitCondition::wait call that does not get finished.
      Could this be a race or blocking condition?

      (gdb) info threads
      5 Thread 0x42803960 (LWP 6160) 0x0000003e873bd9a2 in poll ()
      from /lib64/tls/libc.so.6
      3 Thread 0x41401960 (LWP 6158) 0x0000003e880089ba in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/tls/libpthread.so.0
      2 Thread 0x40a00960 (LWP 6157) 0x0000003e880089ba in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/tls/libpthread.so.0

      • 1 Thread 0x2a97c98080 (LWP 6153) 0x0000003e880089ba in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/tls/libpthread.so.0

      (gdb) thread
      [Current thread is 1 (Thread 0x2a97c98080 (LWP 6153))]

      (gdb) thread 5
      [Switching to thread 5 (Thread 0x42803960 (LWP 6160))]#0 0x0000003e873bd9a2 in poll () from /lib64/tls/libc.so.6

      (gdb) bt
      #0 0x0000003e873bd9a2 in poll () from /lib64/tls/libc.so.6
      #1 0x0000003e8942822e in ?? () from /usr/lib64/libglib-2.0.so.0
      #2 0x0000003e894288eb in g_main_context_iteration ()
      from /usr/lib64/libglib-2.0.so.0
      #3 0x0000002a97a5d385 in QEventDispatcherGlib::processEvents (this=0xbe5e30,
      flags=

      {i = 36}) at kernel/qeventdispatcher_glib.cpp:414
      #4 0x0000002a97a2f193 in QEventLoop::processEvents (
      this=<value optimized out>, flags={i = 36}

      )
      at ../../include/QtCore/../../src/corelib/global/qglobal.h:2187
      #5 0x0000002a97a2f35b in QEventLoop::exec (this=0x42803120, flags=

      {i = 0}

      )
      at ../../include/QtCore/../../src/corelib/global/qglobal.h:2203
      #6 0x0000002a97930583 in QThread::exec (this=<value optimized out>)
      at ../../include/QtCore/../../src/corelib/global/qglobal.h:2188
      #7 0x0000002a97a0ed15 in QDnotifySignalThread::run (this=0x5dfec0)
      at io/qfilesystemwatcher_dnotify.cpp:179
      #8 0x0000002a97933eb6 in QThreadPrivate::start (arg=0x5dfec0)
      at thread/qthread_unix.cpp:266
      #9 0x0000003e8800610a in start_thread () from /lib64/tls/libpthread.so.0
      #10 0x0000003e873c68c3 in clone () from /lib64/tls/libc.so.6
      #11 0x0000000000000000 in ?? ()

      I'm using a SMP environment with stock RHEL4 Update 4:

      1. cat /etc/redhat-release
        Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
      1. uname -a
        Linux host 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux

      Attachments

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

        Activity

          People

            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            janichol Andy Nichols
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes