PDA

View Full Version : [Qt4.1]program segfault after upgrading from 4.0.1 to 4.1



patcito
7th February 2006, 23:24
I did make clean and qmake -project and qmake . It does compile but it segfaults on start. Any idea what could be wrong?
here is the whole source http://p80.free.fr/cutepos.tar.bz2

Thanx in advance

Pat

jacek
8th February 2006, 00:21
I had to edit cutepos.pro file, remove "delagate.h" from HEADERS and add "delegate.cpp" to SOURCES to compile your project, but I don't get any segmentation faults when it starts (I'm using PLD Linux and Qt 4.1.0).

Try running "gdb ./cutepos" then type "run" and when it crashes type "bt" and post the result.

PS. Next time, please run "make clean" before creating the archive with your project.

patcito
8th February 2006, 00:46
I found what was the problem.
I display a mysql table in a Qtreeview and I fill the treeview on startup, I commented out the function that fills the treeview and it doesn't crash now but when I click on a button on my gui that fills the tableview with mysql, it crashes again so I know what is my problem but I have no idea how to fix it
it's something to do with mysql :)

any idea? i'll try gdb now

patcito
8th February 2006, 00:51
ok here is the backtrace:


(gdb) run
Starting program: /home/pat/myprojecs/cutepos/cutepos
[Thread debugging using libthread_db enabled]
[New Thread -1226066240 (LWP 4654)]
true
"bracelet"
QSqlError(-1, """", """")
"select id,ref,numserie,prixvente,brand from articles_montres where atricletype='bracelet'"
"select id,ref,numserie,prixvente,brand from articles_montres where atricletype='bracelet'"

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1226066240 (LWP 4654)]
0xb741869c in mysql_stmt_fetch () from /usr/lib/libmysqlclient.so.15
(gdb) bt
#0 0xb741869c in mysql_stmt_fetch () from /usr/lib/libmysqlclient.so.15
#1 0xb7e64a4e in QMYSQLDriver::QMYSQLDriver () from /usr/lib/libQtSql.so.4
#2 0xb7e4a43b in QSqlQuery::seek () from /usr/lib/libQtSql.so.4
#3 0xb7eaf55b in QSqlQueryModel::data () from /usr/lib/libQtSql.so.4
#4 0xb7d16f6a in QItemDelegate::paint () from /usr/lib/libQtGui.so.4
#5 0xb7d045cb in QTableView::paintEvent () from /usr/lib/libQtGui.so.4
#6 0xb7a14c19 in QWidget::event () from /usr/lib/libQtGui.so.4
#7 0xb7c177c4 in QFrame::event () from /usr/lib/libQtGui.so.4
#8 0xb7c8fa6e in QAbstractScrollArea::viewportEvent () from /usr/lib/libQtGui.so.4
#9 0xb7ce59c2 in QAbstractItemView::viewportEvent () from /usr/lib/libQtGui.so.4
#10 0xb7c8e5b1 in QAbstractScrollArea::horizontalScrollBar () from /usr/lib/libQtGui.so.4
#11 0xb79d18a4 in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4
#12 0xb79d2858 in QApplication::notify () from /usr/lib/libQtGui.so.4
#13 0xb7a1ddee in QApplicationPrivate::openPopup () from /usr/lib/libQtGui.so.4
#14 0xb7af3b13 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#15 0xb7af438e in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#16 0xb7af4245 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#17 0xb7af4245 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#18 0xb7af3850 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#19 0xb7af438e in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#20 0xb7af3850 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#21 0xb7af438e in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#22 0xb7af3850 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#23 0xb7af438e in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#24 0xb7af3850 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#25 0xb7af438e in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#26 0xb7af3850 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#27 0xb7af438e in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#28 0xb7af3850 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#29 0xb7af47d6 in QWidgetPrivate::drawWidget () from /usr/lib/libQtGui.so.4
#30 0xb7af4d74 in QWidget::repaint () from /usr/lib/libQtGui.so.4
#31 0xb7a1445c in QWidget::event () from /usr/lib/libQtGui.so.4
#32 0xb7c8fa52 in QAbstractScrollArea::viewportEvent () from /usr/lib/libQtGui.so.4
#33 0xb7ce59c2 in QAbstractItemView::viewportEvent () from /usr/lib/libQtGui.so.4
#34 0xb7c8e5b1 in QAbstractScrollArea::horizontalScrollBar () from /usr/lib/libQtGui.so.4
---Type <return> to continue, or q <return> to quit---
#35 0xb79d18a4 in QApplicationPrivate::notify_helper () from /usr/lib/libQtGui.so.4
#36 0xb79d2858 in QApplication::notify () from /usr/lib/libQtGui.so.4
#37 0xb788143d in QCoreApplication::sendPostedEvents () from /usr/lib/libQtCore.so.4
#38 0xb7a39701 in non-virtual thunk to QDesktopWidget::~QDesktopWidget() () from /usr/lib/libQtGui.so.4
#39 0xb787ea14 in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#40 0xb787ec66 in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#41 0xb7881601 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4
#42 0xb79d15c7 in QApplication::exec () from /usr/lib/libQtGui.so.4
#43 0x0804dc76 in main ()

patcito
8th February 2006, 01:27
here is the valgrind stuff (sorry if it's too long):



==6243== Conditional jump or move depends on uninitialised value(s)
==6243== at 0x426D5BC: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x426FE61: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4247D5E: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424D2DC: QPainter::drawPath(QPainterPath const&) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424B29C: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424CE88: QPainter::drawRects(QRect const*, int) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424CFFC: QPainter::fillRect(QRect const&, QBrush const&) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x435AAD0: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x437662D: QPlastiqueStyle::drawComplexControl(QStyle::Comple xControl, QStyleOptionComplex const*, QPainter*, QWidget const*) const (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43FA925: QScrollBar::paintEvent(QPaintEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x41D00B4: QWidget::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43FAF51: QScrollBar::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243==
==6243== Conditional jump or move depends on uninitialised value(s)
==6243== at 0x426D5C0: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x426FE61: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4247D5E: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424D2DC: QPainter::drawPath(QPainterPath const&) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424B29C: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424CE88: QPainter::drawRects(QRect const*, int) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x424CFFC: QPainter::fillRect(QRect const&, QBrush const&) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x435AAD0: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x437662D: QPlastiqueStyle::drawComplexControl(QStyle::Comple xControl, QStyleOptionComplex const*, QPainter*, QWidget const*) const (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43FA925: QScrollBar::paintEvent(QPaintEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x41D00B4: QWidget::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43FAF51: QScrollBar::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243==
==6243== Use of uninitialised value of size 4
==6243== at 0x4987EB3: mysql_stmt_fetch (in /usr/lib/libmysqlclient.so.15.0.0)
==6243== by 0x4063053: (within /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x404A2D5: QSqlQuery::seek(int, bool) (in /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x40AA880: QSqlQueryModel::data(QModelIndex const&, int) const (in /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x44B31CF: QItemDelegate::paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x44A0F4A: QTableView::paintEvent(QPaintEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x41D00B4: QWidget::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43BE7C3: QFrame::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4430B63: QAbstractScrollArea::viewportEvent(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x44834F8: QAbstractItemView::viewportEvent(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x442F808: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4190F29: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243==
==6243== Invalid write of size 1
==6243== at 0x4987EB3: mysql_stmt_fetch (in /usr/lib/libmysqlclient.so.15.0.0)
==6243== by 0x4063053: (within /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x404A2D5: QSqlQuery::seek(int, bool) (in /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x40AA880: QSqlQueryModel::data(QModelIndex const&, int) const (in /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x44B31CF: QItemDelegate::paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x44A0F4A: QTableView::paintEvent(QPaintEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x41D00B4: QWidget::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43BE7C3: QFrame::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4430B63: QAbstractScrollArea::viewportEvent(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x44834F8: QAbstractItemView::viewportEvent(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x442F808: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4190F29: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== Address 0x569 is not stack'd, malloc'd or (recently) free'd
==6243==
==6243== Process terminating with default action of signal 11 (SIGSEGV)
==6243== Access not within mapped region at address 0x569
==6243== at 0x4987EB3: mysql_stmt_fetch (in /usr/lib/libmysqlclient.so.15.0.0)
==6243== by 0x4063053: (within /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x404A2D5: QSqlQuery::seek(int, bool) (in /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x40AA880: QSqlQueryModel::data(QModelIndex const&, int) const (in /usr/lib/libQtSql.so.4.1.0)
==6243== by 0x44B31CF: QItemDelegate::paint(QPainter*, QStyleOptionViewItem const&, QModelIndex const&) const (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x44A0F4A: QTableView::paintEvent(QPaintEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x41D00B4: QWidget::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x43BE7C3: QFrame::event(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4430B63: QAbstractScrollArea::viewportEvent(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x44834F8: QAbstractItemView::viewportEvent(QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x442F808: (within /usr/lib/libQtGui.so.4.1.0)
==6243== by 0x4190F29: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/libQtGui.so.4.1.0)
==6243==
==6243== ERROR SUMMARY: 270 errors from 32 contexts (suppressed: 0 from 0)
==6243== malloc/free: in use at exit: 904,303 bytes in 14,443 blocks.
==6243== malloc/free: 123,453 allocs, 109,010 frees, 12,793,535 bytes allocated.
==6243== For counts of detected errors, rerun with: -v
==6243== searching for pointers to 14,443 not-freed blocks.
==6243== checked 2,522,792 bytes.
==6243==
==6243== LEAK SUMMARY:
==6243== definitely lost: 20 bytes in 1 blocks.
==6243== possibly lost: 1,952 bytes in 68 blocks.
==6243== still reachable: 902,331 bytes in 14,374 blocks.
==6243== suppressed: 0 bytes in 0 blocks.
==6243== Use --leak-check=full to see details of leaked memory.
Segmentation fault

jacek
8th February 2006, 01:48
Did you upgrade MySQL libs recently?

patcito
8th February 2006, 02:11
yes I did, I used to use 4.1 before so /usr/lib/libmysqlclient.so.14.0.0 now I use /usr/lib/libmysqlclient.so.15.0.0, you think that might be the problem?

jacek
8th February 2006, 02:32
yes I did, I used to use 4.1 before so /usr/lib/libmysqlclient.so.14.0.0 now I use /usr/lib/libmysqlclient.so.15.0.0, you think that might be the problem?
It crashes when the execution flow enters libmysqlclient, so if you did upgrade that library, it might be the cause.

But first write a small program that connects to the database and fetches some data, if it doesn't crash the problem is in your code for 100%, if it crashes it is more likely that the problem in lack of binary compatibility between two versions of libmysqlclient.

If you are using plugins, you can try to recompile QMYSQL driver, otherwise you will have to recompile whole Qt.

patcito
8th February 2006, 02:59
I did a basic program and it segfaults too, I'll report it to the kubuntu guys thanx.

Pat

Update: here is the test program: http://p80.free.fr/basicmysql.tar.bz2 could you confirm it doesn't crash for you please? it displays mysql users in a qtableview, you can modify connection.h to change the user password

jacek
8th February 2006, 16:00
here is the test program: http://p80.free.fr/basicmysql.tar.bz2 could you confirm it doesn't crash for you please? it displays mysql users in a qtableview, you can modify connection.h to change the user password
My idea of a small program is:
#include <QtDebug>
#include <QApplication>
#include <QVariant>

#include "connection.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

createConnection();

QSqlQuery q( "SELECT * FROM user" );
qDebug() << q.lastError();
while( q.next() ) {
qDebug() << q.value( 0 ) << q.value( 1 );
}
}

Anyway, it seems that there is a bug in Qt 4.1.0. If I change CutePOS::initialize() to:
QSqlQueryModel *model = new QSqlQueryModel;
model->setQuery( "select * from user" );
ui.articlestableView->setModel(model);it works.

patcito
10th February 2006, 01:15
Thanx a lot for your help. I compiled a snapshot of Qt4.1.1 and it does run now!