[Qt-interest] Static destructors errors

marc at mferland.net marc at mferland.net
Fri Oct 16 15:54:29 CEST 2009


Hi all,

I've posted about this problem a while ago but didn't have the time to  
correctly answer the questions/requests that was asked to me (sorry  
about that!). So here I go again.

I'm currently working on a large project involving Qt 4.5.2 and we  
have a really strange problem when closing the application. More  
precisely, the application crashes 50% of the time in different static  
destructors. See the following stack traces for more information:

Crash in ~QGlobalStaticDeleter
#0  0x0000003b17a75bd0 in malloc_consolidate (av=0x3b17d69e80) at  
malloc.c:5095
#1  0x0000003b17a77448 in _int_free (av=0x3b17d69e80, p=0x1633aa0,  
have_lock=<value optimized out>) at malloc.c:4968
#2  0x0000003edfd4a7a3 in ~QVector (this=<value optimized out>,  
__in_chrg=<value optimized out>) at  
../../src/corelib/tools/qvector.h:114
#3  QGlobalStaticDeleter<QVector<QCustomTypeInfo>  
 >::~QGlobalStaticDeleter (this=<value optimized out>,  
__in_chrg=<value optimized out>) at  
../../src/corelib/global/qglobal.h:1633
#4  0x0000003b17a36bc0 in __cxa_finalize (d=0x3ee002a210) at cxa_finalize.c:56
#5  0x0000003edfc48b36 in __do_global_dtors_aux () from  
/usr/lib64/libQtCore.so.4
#6  0x0000000000000000 in ?? ()

Crash in timerIdsDestructorFunction
#0  0x0000003b17a75bd0 in malloc_consolidate (av=0x3b17d69e80) at  
malloc.c:5095
#1  0x0000003b17a77448 in _int_free (av=0x3b17d69e80, p=0x1822d60,  
have_lock=<value optimized out>) at malloc.c:4968
#2  0x0000003edfd33a9a in timerIdsDestructorFunction () at  
kernel/qabstracteventdispatcher.cpp:74
#3   
timerIdsDestructorFunction__dest_class__::~timerIdsDestructorFunction__dest_class__ () at  
kernel/qabstracteventdispatcher.cpp:76
#4  0x0000003b17a36bc0 in __cxa_finalize (d=0x3ee002a210) at cxa_finalize.c:56
#5  0x0000003edfc48b36 in __do_global_dtors_aux () from  
/usr/lib64/libQtCore.so.4
#6  0x0000000000000000 in ?? ()

As a side note, we were also having crashes with every static QHash  
and QMap container defined in the application. Replacing these static  
containers with dynamically allocated ones resolved the problem. I  
guess the problem we are having right now is with static containers  
defined inside of Qt itself. The question is why!!??

I also made a small test program with static containers but didn't  
have any problems (tried valgrind and nothing popped up), so I guess  
we are doing something wrong here... I just don't know were to look  
any more!

We don't really know what to check anymore so any help would be  
greatly appreciated! :)

Regards,

Marc
Note: I can post the small test program or valgrind runs if any of you  
are interested.





More information about the Qt-interest-old mailing list