[Interest] Destructor appearing twice in the stack trace?

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Mon Nov 9 17:02:04 CET 2015


>
> Are you sure that in some way it’s not child of itself ?
> Qt automatically destroy all children of an QObject … and I really don’t
> know how safe is Qt to assign itself as child.
>

The parent is set upon creation, to the class which creates and manages it.
But I will triple check. However, in this case, I would have calls to
~RendererInterface, ~QObject, ~RendererInterface, ~QObject.

I have even removed the qDebug line, and let an empty destructor, just in
case (I installed a message handler so it could be in cause). Same result.
I have likely another part of the code which is corrupting this QObject,
but I wonder how this is even possible to have a stack trace like that.

Upon

Etienne

2015-11-09 16:55 GMT+01:00 Etienne Sandré-Chardonnal <etienne.sandre at m4x.org
>:

> Dear Gian,
>
> I have checked that of course. But this is not the case, the destructor
> has been reduced to a single call to qDebug (see my other mail) and the
> error persists.
> Also, when I set a breakpoint on the qDebug line, the debugger halts on
> the second call (both are already in the stack) which is again very
> suprising.
>
> I use the debugger often and never had any problem like that before.
>
> Cheers,
>
> Etienne
>
>
>
> 2015-11-09 16:43 GMT+01:00 Gian Maxera <gmaxera at gmail.com>:
>
>>
>> > On 9 Nov 2015, at 15:38, Konstantin Tokarev <annulen at yandex.ru> wrote:
>> >
>> >
>> >
>> > 09.11.2015, 18:22, "Etienne Sandré-Chardonnal" <etienne.sandre at m4x.org
>> >:
>> >> Dear all,
>> >>
>> >> I am debugging an app which crashes when an object is being deleted.
>> The debuggers halt on a segmentation fault inside QObject destructor. The
>> object deletion was requested by a call to deleteLater()
>> >>
>> >> Here is what I get in the stack trace:
>> >>
>> >> 0    QObject::~QObject    qobject.cpp    993    0x7ffff62c7580
>> >> 1    RendererInterface::~RendererInterface    rendererinterface.cpp
>> 119    0x60664f
>> >> 2    RendererInterface::~RendererInterface    rendererinterface.cpp
>> 137    0x60667e
>> >> 3    qDeleteInEventHandler    qobject.cpp    4391    0x7ffff62d06e5
>> >>
>> >> How is it possible to have the destructor twice in the stack?? At the
>> beginning I was thinking this was a GDB bug (GDB/MinGW under windows is
>> buggy) but I get the same result when compiling the app under linux.
>> >>
>> >> Any idea how this can happen?
>> >
>> > Answer is definitely around lines 119-137 of rendererinterface.cpp
>>
>>
>> You are calling delete on the same object into the destructor. You are
>> doing something like that:
>>
>> delete this
>>
>> inside the destructor.
>>
>> Maybe there is some internal variable that got the “this” value and force
>> the object to try to destroy itself.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151109/9238fa12/attachment.html>


More information about the Interest mailing list