Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
4.7.1
-
None
Description
On X11 QWidget crashes at destructor when the QApplication was deleted beforehand. On Windows it works.
As this behaviour isn't documented and only crashes on X11 I suppose it's a bug.
Here is the dump of a session showing the issue:
[hugo@thinkpadugo foo 4.7] $ cat > main.cpp
#include <QtCore>
#include <QtGui>
int main(int argc, char** argv) {
QApplication* app = new QApplication(argc, argv);
QWidget* w = new QWidget;
w->show();
app->exec();
delete app;
delete w;
}
[hugo@thinkpadugo foo 4.7] $ qmake -project
[hugo@thinkpadugo foo 4.7] $ qmake
[hugo@thinkpadugo foo 4.7] $ make
g++ -c -m64 -pipe -march=x86-64 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT
-DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-I/usr/share/qt/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore
-I/usr/include/QtGui -I/usr/include -I. -I. -o main.o main.cpp
g++ m64 -Wl,hash-style=gnu -Wl,-as-needed -Wl,-O1 -o foo main.o
-L/usr/lib -lQtGui -lQtCore -lpthread
[hugo@thinkpadugo foo 4.7] $ ./foo
Segmentation fault
[hugo@thinkpadugo foo 4.7] $ gdb ./foo
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/foo/foo...(no debugging symbols found)...done.
(gdb) r
Starting program: /tmp/foo/foo
[Thread debugging using libthread_db enabled]
Qt: gdb: -nograb added to command-line options.
Use the -dograb option to enforce grabbing.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff73096d1 in QX11WindowSurface::~QX11WindowSurface (this=0x64f050,
__in_chrg=<value optimized out>) at
/home/hugo/src/qt/src/gui/painting/qwindowsurface_x11.cpp:84
84 XFreeGC(X11->display, gc);
(gdb) bt
#0 0x00007ffff73096d1 in QX11WindowSurface::~QX11WindowSurface (this=0x64f050,
__in_chrg=<value optimized out>) at
/home/hugo/src/qt/src/gui/painting/qwindowsurface_x11.cpp:84
#1 0x00007ffff730974c in QX11WindowSurface::~QX11WindowSurface (this=0x64f050,
__in_chrg=<value optimized out>) at
/home/hugo/src/qt/src/gui/painting/qwindowsurface_x11.cpp:87
#2 0x00007ffff7303203 in QWidgetBackingStore::~QWidgetBackingStore
(this=0x79a960, __in_chrg=<value optimized out>) at
/home/hugo/src/qt/src/gui/painting/qbackingstore.cpp:883
#3 0x00007ffff70be473 in QWidgetBackingStoreTracker::destroy (this=0x793260)
at /home/hugo/src/qt/src/gui/kernel/qwidget.cpp:205
#4 0x00007ffff70c15d2 in QWidgetPrivate::deleteExtra (this=0x673ff0) at
/home/hugo/src/qt/src/gui/kernel/qwidget.cpp:1750
#5 0x00007ffff70beb0c in QWidgetPrivate::~QWidgetPrivate (this=0x673ff0,
__in_chrg=<value optimized out>) at
/home/hugo/src/qt/src/gui/kernel/qwidget.cpp:318
#6 0x00007ffff70bed94 in QWidgetPrivate::~QWidgetPrivate (this=0x673ff0,
__in_chrg=<value optimized out>) at
/home/hugo/src/qt/src/gui/kernel/qwidget.cpp:323
#7 0x00007ffff6251b58 in QScopedPointerDeleter<QObjectData>::cleanup
(pointer=0x673ff0) at
../../include/QtCore/../../../qt/src/corelib/tools/qscopedpointer.h:62
#8 0x00007ffff62505e9 in QScopedPointer<QObjectData,
QScopedPointerDeleter<QObjectData> >::~QScopedPointer (this=0x604658,
__in_chrg=<value optimized out>)
at ../../include/QtCore/../../../qt/src/corelib/tools/qscopedpointer.h:100
#9 0x00007ffff6249825 in QObject::~QObject (this=0x604650, __in_chrg=<value
optimized out>) at /home/hugo/src/qt/src/corelib/kernel/qobject.cpp:817
#10 0x00007ffff70c0e8d in QWidget::~QWidget (this=0x604650, __in_chrg=<value
optimized out>) at /home/hugo/src/qt/src/gui/kernel/qwidget.cpp:1477
#11 0x00007ffff70c0fee in QWidget::~QWidget (this=0x604650, __in_chrg=<value
optimized out>) at /home/hugo/src/qt/src/gui/kernel/qwidget.cpp:1620
#12 0x00000000004008de in main ()