[Qt-interest] Hiding rows and columns of buttons in a grid layout - segfault

Colin S. Miller no-spam-thank-you at csmiller.demon.co.uk
Tue Sep 21 21:39:07 CEST 2010


Camilo Polymeris wrote:
 >Colin S. Miller wrote:
>> As you appear to be running under a *NIX, and assuming that this is Linux or MacOS,
>> could you run the code under Valgrind[1], and see if any errors are reported before
>> your app crashes?
>>
> Ok. Errors reported by 'valgrind ./emutrix' before crash:
> http://pastebin.com/Pc35EVzB
> I have never used valgrind, so I don't know what to make of this.
> Thank you for your help.
>

The first error from valgrind is

==27725== Invalid read of size 8
==27725==    at 0x407FA9: MainWindow::setButtonGroupVisible(QButtonGroup const*, bool) (mainwindow.cc:72)
==27725==    by 0x4EF034: MainWindow::on_con0202_toggled(bool) (mainwindow_slots.cc:107)
==27725==    by 0x4F397B: MainWindow::qt_metacall(QMetaObject::Call, int, void**) (moc_mainwindow.cpp:154)
==27725==    by 0x5F26E3E: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (in /usr/lib/libQtCore.so.4.6.2)
==27725==    by 0x59685B1: QAbstractButton::toggled(bool) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x5683A37: QAbstractButton::setChecked(bool) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x5683A24: QAbstractButton::setChecked(bool) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x56836C9: ??? (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x568397B: QAbstractButton::mouseReleaseEvent(QMouseEvent*) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x5323581: QWidget::event(QEvent*) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x52CD22B: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x52D3ECA: QApplication::notify(QObject*, QEvent*) (in /usr/lib/libQtGui.so.4.6.2)


The == 27725 == was the PID (process ID) of your program; it is not that important.

Your program tried to read 8 bytes from a pointer to uninitialised data; there rest
is a partial stack track to what caused the error.

You can use
valgrind --num-callers=99 ./myprog arg1 arg2 arg3

to increase the stack depth reported from valgrind.

==27725==  Address 0x14f625f8 is 24 bytes inside a block of size 512 free'd
==27725==    at 0x4C280BD: free (vg_replace_malloc.c:366)
==27725==    by 0x4EE6CB: QList<QAbstractButton*>::free(QListData::Data*) (qlist.h:649)
==27725==    by 0x4EE1F5: QList<QAbstractButton*>::~QList() (qlist.h:621)
==27725==    by 0x407F7B: MainWindow::setButtonGroupVisible(QButtonGroup const*, bool) (mainwindow.cc:70)
==27725==    by 0x4EF034: MainWindow::on_con0202_toggled(bool) (mainwindow_slots.cc:107)
==27725==    by 0x4F397B: MainWindow::qt_metacall(QMetaObject::Call, int, void**) (moc_mainwindow.cpp:154)
==27725==    by 0x5F26E3E: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (in /usr/lib/libQtCore.so.4.6.2)
==27725==    by 0x59685B1: QAbstractButton::toggled(bool) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x5683A37: QAbstractButton::setChecked(bool) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x5683A24: QAbstractButton::setChecked(bool) (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x56836C9: ??? (in /usr/lib/libQtGui.so.4.6.2)
==27725==    by 0x568397B: QAbstractButton::mouseReleaseEvent(QMouseEvent*) (in /usr/lib/libQtGui.so.4.6.2)


The program attempted to call free() [ or delete ] with a pointer 24 bytes into an allocated block.

The last report is the same SIGSEGV that caused your program to crash under GDB.


Either Qt is buggy (unlikely as valgrind is hosted by KDE, who use Qt, and KDE has been run under valgrind),
or you are passing bad pointers into Qt.

Could you increase the stack depth, and see if that gives you any clues as to what is going on?


HTH,
Colin S. Miller



More information about the Qt-interest-old mailing list