Results 1 to 7 of 7

Thread: Linux QT4 app hangs on exit

  1. #1
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Linux QT4 app hangs on exit

    Hi,

    I've been finishing off a port of a GIUI from QT3 to QT4, and have come across this problem on Linux.

    The program starts up, loads a couple of dlls (Which widgets displayed in a QStrackedWidget, and when I exit, and clear everything up, the app hangs. It gets as far as the bottom of my main, where I have put :-

    Printf("We have reached the end\n" );
    return 0;

    So I know it's right at the end. However something is hanging, since when I exit, we do not return to the prompt.

    The same problem does not occur on Windows. I'm a bit stumped as to what may be causing this, and was wondering whether anyone had come across this.

    I have printed the stack below. I'm currently using QT - 4.5.1, but the same problem occurred in an older version of QT4.

    My Linux version is :-

    Linux davidg-linux 2.6.24-24-generic #1 SMP Wed Apr 15 15:54:25 UTC 2009 i686 GNU/Linux

    [Thread debugging using libthread_db enabled]
    [New Thread 0xb6d138d0 (LWP 10793)]
    [New Thread 0xb69bab90 (LWP 10796)]
    We have reached the end << ---- I printed this out right at the end of my main(), before returning zero
    [Thread 0xb69bab90 (LWP 10796) exited]

    << I then waited for a bit and did ctl-c, to break into the program, and print the stack >>

    Program received signal SIGINT, Interrupt.
    [Switching to Thread 0xb6d138d0 (LWP 10793)]
    0xb7f8a410 in __kernel_vsyscall ()
    (gdb) bt
    #0 0xb7f8a410 in __kernel_vsyscall ()
    #1 0xb7018553 in __lll_lock_wait_private ()
    from /lib/tls/i686/cmov/libpthread.so.0
    #2 0xb701596a in _L_lock_23 () from /lib/tls/i686/cmov/libpthread.so.0
    #3 0xb7015718 in pthread_cond_destroy@@GLIBC_2.3.2 ()
    from /lib/tls/i686/cmov/libpthread.so.0
    #4 0xb713a818 in ~QMutexPrivate (this=0x8112048)
    at /var/tmp/qt-x11-src-4.5.1/src/corelib/thread/qmutex_unix.cpp:70
    #5 0xb7135be8 in ~QMutex (this=0xfffffe00)
    at /var/tmp/qt-x11-src-4.5.1/src/corelib/thread/qmutex.cpp:134
    #6 0x080695c0 in __tcf_0 ()
    #7 0xb6dcf084 in exit () from /lib/tls/i686/cmov/libc.so.6
    #8 0xb6db7458 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
    #9 0x08051bc1 in _start ()
    (gdb)

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Linux QT4 app hangs on exit

    can u print your main()?
    may be u should not return 0, return app.exe()

    Qt Code:
    1. int main(..)
    2. {
    3. QApplication app();
    4. ...
    5. widget.show();
    6. return app.exe();
    7. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linux QT4 app hangs on exit

    I have stripped out some stuff that sets up logging etc in my main, and it basically looks like this :-

    Qt Code:
    1. int main( int argc, char** argv )
    2. {
    3. QApplication app( argc, argv );
    4.  
    5. qApp->setStyle( new QCleanlooksStyle() );
    6.  
    7. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
    8.  
    9. MainDialog dialog( 0, Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint );
    10. dialog.exec();
    11.  
    12. printf( "We have reached the end\n" );
    13. return 0;
    14. }
    To copy to clipboard, switch view to plain text mode 

    As I said previously, I load a number of shared objects (dll's in windows), which are the widgets I display in my widget stack.

    On Linux, if I do not load the shared object, the app exits fine, but it seems the mere act of calling

    Qt Code:
    1. NewPage.hinstLib = dlopen( Name.c_str(), RTLD_LAZY);
    To copy to clipboard, switch view to plain text mode 

    on one my shared objects, causes the app to get stuck.

    BTW - This all works fine on windows, linux and solaris, with QT3.

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Linux QT4 app hangs on exit

    did you tried returning app.exe() ?

    edit:-> also use show() in maindialog instead of exec()

  5. #5
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linux QT4 app hangs on exit

    I changed the code as follows:

    Qt Code:
    1. MainDialog dialog( 0, Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint );
    2. dialog.show();
    3.  
    4. return app.exec();
    To copy to clipboard, switch view to plain text mode 

    But I still get the hang on Linux. Looking at the output from GDB, it's still the same as in my initial post.

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Linux QT4 app hangs on exit

    i bail out

  7. #7
    Join Date
    Jun 2009
    Posts
    66
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linux QT4 app hangs on exit

    I've resolved this issue in a strange way, but will investigate the cause later.

    In my App I had the following :-

    - Main app (exe).
    - A number of widget which are built as shared object (.so/.dll).
    - A static library which is linked into the main app and shared objects (.a/.lib).

    On windows and solaris, everything is fine, but on linux, this method, causes the main app to hang on exit, when cleaning up and closing the shared objects.

    I got around the problem by changing the structure to :-

    - Main app (exe).
    - A number of widget which are built as shared object (.so/.dll).

    Now rather than having a static library linked in, which contains the shared code, which is duplciated in each shared object, I include the C++ files in each individual *.pro file for each shared object. Building like this stops the hang.

    This is a very strange issue, but as I said, it resolves my issue for now, and enables me to conitnue with my dev on QT4.

Similar Threads

  1. Which Linux distribution is best for building compatible apps?
    By Oxidative in forum Installation and Deployment
    Replies: 8
    Last Post: 9th July 2009, 16:13
  2. Replies: 5
    Last Post: 15th January 2009, 09:03
  3. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Tags for this Thread

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.