[Qt-interest] Static destructors errors
marc at mferland.net
marc at mferland.net
Fri Oct 16 17:04:25 CEST 2009
Quoting marc at mferland.net:
> Quoting "Colin S. Miller" <no-spam-thank-you at csmiller.demon.co.uk>:
>
>> marc at mferland.net wrote:
>>
>>> 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:
>>>
>> <snip!>
>>
>> Marc,
>> Do either of the destructors use data in the other class?
>>
>> Colin S. Miller
>
> Hi Colin,
>
> I don't think so... These are internally (private) used containers so
> I don't really how they are used. Your thinking that maybe one is
> destroyed before the other?
>
> On my side, I've checked if our problematic static containers where
> indeed empty _before_ closing the application and it doesn't really
> change anything whether they are empty or not.
>
> One detail I forgot to mention in my last post is that in the
> timerDestructor case, the problem is caused by a corrupted iterator
> inside a for-loop. I've traced the loop in a debugger and for some
> reason, calling a delete changes the value of the iterator... malloc
> bug? (would be really surprising IMHO).
>
> The for loop looks like this (from qabstracteventdispatcher.cpp:70):
> static void timerIdsDestructorFunction()
> {
> // start at one, the first bucket is pre-allocated
> for (int i = 1; i < NumberOfBuckets; ++i)
> delete [] static_cast<int *>(timerIds[i]);
> }
>
> Regards,
>
> Marc
If I place breakpoints inside the timerIdsDestructorFunction and add a
watch point for the iterator 'i', I get the following:
(gdb) watch i
Watchpoint 9: i
(gdb) n
Watchpoint 9: i
Old value = 1
New value = 399941192
0x0000003b17a79977 in *__GI___libc_free (mem=0xcc2fd0) at malloc.c:3675
Current language: auto; currently minimal
(gdb)
and the stack trace looks like:
#0 0x0000003b17a79977 in *__GI___libc_free (mem=0xcc2fd0) at malloc.c:3675
#1 0x0000003edfd33a9a in timerIdsDestructorFunction () at
kernel/qabstracteventdispatcher.cpp:74
#2
timerIdsDestructorFunction__dest_class__::~timerIdsDestructorFunction__dest_class__ () at
kernel/qabstracteventdispatcher.cpp:76
#3 0x0000003b17a36bc0 in __cxa_finalize (d=0x3ee002a210) at cxa_finalize.c:56
#4 0x0000003edfc48b36 in __do_global_dtors_aux () from
/usr/lib64/libQtCore.so.4
#5 0x0000000000000000 in ?? ()
Marc
More information about the Qt-interest-old
mailing list