QWidget::show () segmentation fault
Hi all,
I am using Qt3 to develop GUI program. In my program, I provide some toolbars and when user click on it, a window will pop up. But there is a strange behaviour happened. When I clicked on the toolbar, the program crashed and showed "segmentation fault" error. By using gdb, I found out that this happened whenever QWidget::show() executed.
The error happened when I use Qt3 library from my own compilation and running on Debian etch. When I use the Qt3 library provided by Debian Etch, the problem occurred occasionally and unpredictable. But when I use Qt3 library from my own compilation and running on Ubuntu Breezy, the error never occurred.
Has anyone experience problem like mine? Any hints will be appreciated.
Umar Said
Re: QWidget::show () segmentation fault
What else happens when the widget is shown?
You should post some code.
Make sure you don't modify that widget from other threads.
Re: QWidget::show () segmentation fault
When I was coding on two distros, I made sure that the versions and releases are the same. If there is a difference, even a slight difference, I usually recreate project and rebuild project. You also need to check the documentation of the two, there may be changes, and your implementation somehow causes the segmentation fault.
Re: QWidget::show () segmentation fault
Thanks very much for all your reply.
I intended to put an attachment of my source in tar.bz2, but due to my very very bad internet connection, I post them here. Sorry for the long codes.
The main problem is displaying dialog CreateHull.ui when I click on a toolbar. Below is the source code of it. I hope you can reproduce the error. Maybe later when my internet connection get better, I will attach the source in tar.bz2 format.
I compile and run the code in two different computer. One on Debian Etch using libqt3-mt 3.3.7-4 and gcc version 3.3.6, while the other on Ubuntu Breezy using my own compiled qt3 3.3.7 and gcc 4.0.2. The program run normal on Ubuntu, when I click the toolbar, the CreateHull dialog pop up. But when I run the same program on Debian, the program exited with segmentation error.
CreateHullBase.ui
Code:
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>CreateHullBase</class>
<widget class="QDialog">
<property name="name">
<cstring>CreateHullBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>201</width>
<height>122</height>
</rect>
</property>
<property name="caption">
<string>Outer Hull</string>
</property>
<property name="icon">
<pixmap>image0</pixmap>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLayoutWidget" row="0" column="0">
<property name="name">
<cstring>layout7</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLineEdit" row="0" column="1">
<property name="name">
<cstring>txtBreadth</cstring>
</property>
</widget>
<widget class="QLineEdit" row="1" column="1">
<property name="name">
<cstring>txtDepth</cstring>
</property>
</widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Breadth :</string>
</property>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>Depth :</string>
</property>
</widget>
</grid>
</widget>
<spacer row="1" column="0">
<property name="name">
<cstring>spacer6</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QLayoutWidget" row="2" column="0">
<property name="name">
<cstring>layout8</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer>
<property name="name">
<cstring>spacer7</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>btnCreate</cstring>
</property>
<property name="text">
<string>&Create</string>
</property>
<property name="accel">
<string>Alt+C</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>btnClose</cstring>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</hbox>
</widget>
</grid>
</widget>
<images>
<image name="image0">
<data format="PNG" length="477">89504e470d0a1a0a0000000d49484452000000100000001008060000001ff3ff61000001a449444154789c9d9331481b6118869f8bcde19004940e1d345320d2e51c6d860ec5160411a4a4118a09073786cc0117c9e2261a220ebd9fd0a11a101c840ca90856316d37bb58d2de620669d586a61789e291eb76782647b5dff4bfffffbecffff1c12701944a25bbd56a71dfd2344d92745db763b1189148e45e61c330a856abf800cfb01002455190651945511042605916ed76dbc93cf0fa4108c1d6c612d5f72bc8721fed8bdfcc6a592ccb22994c3a3e9f17209fcfb3f67685bece4fae7e7dc077f985d585690a8582cbe77420cb72176460789cc6d1bca343c17e6ab55a6f00c08f3915eba4eee8a1e20e838fe779579861e2d9087fcc4ba2d1a837c03aa9737dfcdd65d8fb74c8d3b151b6d73516dfec934ea75def9e3300c8e5727cfe7606402677c0e4cb0ca954ea6e8062bdc9f3a9579c364cd4ec32e170185555bb7c9e80f317aff97adc00e0e1a3612a950ae572b9cbe79ac15071c7397f5cccb0b97be46835bb4c3c1ea7d96cf606dcdc854020c093d111afe67a036cdb762e4dd3ec69ee743a00f8fd7e37c0308cff5aa650288404a0ebbafdafc0ed0a0683241209e92f6d219098fc3e299c0000000049454e44ae426082</data>
</image>
</images>
<connections>
<connection>
<sender>btnClose</sender>
<signal>clicked()</signal>
<receiver>CreateHullBase</receiver>
<slot>accept()</slot>
</connection>
</connections>
<layoutdefaults spacing="6" margin="11"/>
</UI>
Re: QWidget::show () segmentation fault
Could we see the relevant code (not the designed form)? Or run it through a debugger and see backtrace where exactly does it crash.
1 Attachment(s)
Re: QWidget::show () segmentation fault
I have attached the source code. When I compile it using debug config, the backtrace output is below (truncated).
Code:
(gdb) bt
#0 0x0809d77f in ?? ()
#1 0x0804d954 in MainWindow::editFind (this=0x8080de8)
at src/MainWindow.cpp:24
#2 0x08055556 in MainWindowBase::qt_invoke (this=0x8080de8, _id=72,
_o=0xbf88858c) at .moc/moc_MainWindowBase.cpp:123
#3 0x08054a17 in MainWindow::qt_invoke (this=0x8080de8, _id=72, _o=0xbf88858c)
at .moc/moc_MainWindow.cpp:77
#4 0xb7a41d4f in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#5 0xb7a427e0 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#6 0xb7df33ea in QAction::activated () from /usr/lib/libqt-mt.so.3
#7 0xb7baad51 in QAction::internalActivation () from /usr/lib/libqt-mt.so.3
#8 0xb7df3152 in QAction::qt_invoke () from /usr/lib/libqt-mt.so.3
#9 0xb7a41d4f in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#10 0xb7dcaee3 in QSignal::signal () from /usr/lib/libqt-mt.so.3
Actually, I also found this kind of error about a year ago when beginning to use Qt. It also happened in Debian Etch. When I compile it, a warning appeared.
Code:
/usr/bin/ld: warning: libstdc++.so.6, needed by /usr/share/qt3/lib/libqt-mt.so, may conflict with libstdc++.so.5
Re: QWidget::show () segmentation fault
I've just find out that on Ubuntu Feisty (7.10), the code also generated error. The Qt I used is libqt3-mt 3.3.8really3.3.7-0ubuntu5.2. Is this Linux or Qt issue? Anybody willing to try it?