[Qt-interest] seg faults in QApplication destructor?

Alan Ezust alan.ezust at gmail.com
Thu Jan 8 01:57:32 CET 2009


Step 1: post a full stacktrace from the debugger at the point of the
segfault. You might find the answer just from looking at it more
closely.

Segfaults at exit can be caused by all sorts of things, but often I
find that it happens when a child object of the QApplication is being
cleaned up, when it was destroyed already before. How can that happen?
If for example, you added a heap QObject to a pointer collection, but
it also has a parent which is indirectly or directly a child of one of
your QWidgets, or the QApplication. Then before exit, you iterate
through the collection, deleting all the heap objects in it, but they
are still in the childlist of another QObject. So, When the QApp goes
out of scope, it tries to delete all of its QObject children and
descendents in the tree, and you get a segfault when it tries to
delete the same object again.




On Wed, Jan 7, 2009 at 3:33 PM, John Dailey <john.w.dailey at gmail.com> wrote:
> I am working on a QT4.3.4 project that I inherited and it is behaving
> in a manner that seems strange to me.  It consistently seg faults in
> the QApplication destructor (according to GDB anyway).  The back trace
> generated when it does seg fault is not consistant, but it seems to go
> through QHash and free on it's ultimate path to oblivion.  I am a
> novice when it comes to QT and to gui programming in general so I fear
> I may be missing something obvious.
>
> Does anyone have any ideas what could be causing my code to seg fault
> in a somewhat inconsistent manner?  Any recommendations on how I
> proceed to debug this?  Any additional information I could provide to
> help figure this out?
>
> Also, the same code will rarely seg fault shortly after loading.  I
> haven't been able to gather much data on that fault since I haven't
> gotten it to happen in GDB yet...  Perhaps they are related?
>
> Thanks,
> John
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list