PDA

View Full Version : Program crashes at QApplication::exec()



lugarci2
29th January 2017, 00:00
I've been making a little program in a 32 bit machine, and later i tried to compile it on a 64 bit machine (debian testing up-to-date). I thought it should compile and work fine, as i don't use anything 32bit-specific thing. The program compiled and run very well on the 32 bit computer, and compiles fine on the 64 bit computer, but it crashes unexpectedly. I can run the program for a few seconds, and later it crashes. It uses a QAbstractTableModel. When i try to use the debugger, it crashes without even being able to use the program, on the QApplication::exec() function.

Here is the backtrace:


*** Error in `/home/user404/Desarrollo/build-LittleProgram-Desktop-Debug/LittleProgram': free(): invalid pointer: 0x00007fffffffb3e8 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x7ffff5e12bcb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76fa6)[0x7ffff5e18fa6]
/lib/x86_64-linux-gnu/libc.so.6(+0x7779e)[0x7ffff5e1979e]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x1b0d28)[0x7ffff6da9d28]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZNK19QStyledItemDelegate15initStyle OptionEP20QStyleOptionViewItemRK11QModelIndex+0xed )[0x7ffff788f6bd]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZNK19QStyledItemDelegate5paintEP8QP ainterRK20QStyleOptionViewItemRK11QModelIndex+0x4f )[0x7ffff788eaef]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x729a74)[0x7ffff7815a74]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN10QTableView10paintEventEP11QPain tEvent+0x89a)[0x7ffff781f92a]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN7QWidget5eventEP6QEvent+0x290)[0x7ffff7306e80]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN6QFrame5eventEP6QEvent+0x1e)[0x7ffff76cbc8e]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN17QAbstractItemView13viewportEven tEP6QEvent+0x1e3)[0x7ffff77f0ba3]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN23QCoreApplicationPrivate29sendT hroughObjectEventFiltersEP7QObjectP6QEvent+0x91)[0x7ffff6d840a1]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN19QApplicationPrivate13notify_hel perEP7QObjectP6QEvent+0x6c)[0x7ffff72b052c]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6 QEvent+0x2cc)[0x7ffff72b752c]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN16QCoreApplication14notifyIntern alEP7QObjectP6QEvent+0x8d)[0x7ffff6d83f1d]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12Q PaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidge tBackingStore+0x605)[0x7ffff73014e5]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x45 8)[0x7ffff7301ed8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12Q PaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidge tBackingStore+0x196)[0x7ffff7301076]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x45 8)[0x7ffff7301ed8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12Q PaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidge tBackingStore+0x196)[0x7ffff7301076]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x45 8)[0x7ffff7301ed8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12Q PaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidge tBackingStore+0x196)[0x7ffff7301076]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x45 8)[0x7ffff7301ed8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x35 8)[0x7ffff7301dd8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12Q PaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidge tBackingStore+0x196)[0x7ffff7301076]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate22paintSiblingsRe cursiveEP12QPaintDeviceRK5QListIP7QObjectEiRK7QReg ionRK6QPointiP8QPainterP19QWidgetBackingStore+0x45 8)[0x7ffff7301ed8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12Q PaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidge tBackingStore+0x196)[0x7ffff7301076]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x3e564a)[0x7ffff74d164a]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x3e59e3)[0x7ffff74d19e3]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x236cb8)[0x7ffff7322cb8]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN12QApplication15x11ProcessEventEP 7_XEvent+0xebe)[0x7ffff7330d7e]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26e502)[0x7ffff735a502]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2a7)[0x7ffff56807f7]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4aa60)[0x7ffff5680a60]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c)[0x7ffff5680b0c]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN20QEventDispatcherGlib13processE ventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0 x64)[0x7ffff6db4854]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26e5d6)[0x7ffff735a5d6]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN10QEventLoop13processEventsE6QFl agsINS_17ProcessEventsFlagEE+0x3f)[0x7ffff6d827ef]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN10QEventLoop4execE6QFlagsINS_17P rocessEventsFlagEE+0x1b5)[0x7ffff6d82b55]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN16QCoreApplication4execEv+0x99)[0x7ffff6d88bd9]
/home/user404/Desarrollo/build-LittleProgram-Desktop-Debug/LittleProgram(+0x60c5)[0x55555555a0c5]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7ffff5dc22b1]
/home/user404/Desarrollo/build-LittleProgram-Desktop-Debug/LittleProgram(+0x5f2a)[0x555555559f2a]

It seems that im missing some debian package for debugging symbols?, but the crash seems a mistery for me right now... :confused:

anda_skoa
30th January 2017, 09:42
Best way forward is to run a reduced program, e.g. with code commented out, and see when starts/stops crashing.

Since you mention a model try not creating and instantiating the model, i.e. having an empty view.

Cheers,
_

high_flyer
30th January 2017, 10:40
In addition you can simply run it with a debugger, it will probably show you the crashing line and stop execution with the call stack still visible.
Then you can look in the call stack which is the last line in your code - that is the offending line.

lugarci2
30th January 2017, 19:33
Best way forward is to run a reduced program, e.g. with code commented out, and see when starts/stops crashing.

Since you mention a model try not creating and instantiating the model, i.e. having an empty view.

Cheers,

Yes, i forgot to mention that the model loads data from a file, and that if the file isn't there, that is, the model is empty, the program runs fine. I tried commenting code out, and just give static numbers from the model, but it also crashes. And what it surprises me, is that the rows with those static numbers also have a checkbox. The same happens when the real data is there, and if i select the row, it crashes, altough i don't handle selection in my code. Another thing, is that the first time the program at least shows up, i can see the data, and later it crashes, but later when i try to run it again, it crashes before i can see anything.


In addition you can simply run it with a debugger, it will probably show you the crashing line and stop execution with the call stack still visible.
Then you can look in the call stack which is the last line in your code - that is the offending line.
The offending line is in my main function, when i call QApplication::exec(), here is the call stack (i had to put it as CODE):


1 __GI_raise raise.c 58
2 __GI_abort abort.c 89
3 __libc_message libc_fatal.c 175
4 malloc_printerr malloc.c 5046
5 _int_free malloc.c 3902
6 clear qvariant.cpp 291
7 QStyledItemDelegate::initStyleOption qstyleditemdelegate.cpp 333
8 QStyledItemDelegate::paint qstyleditemdelegate.cpp 425
9 QTableViewPrivate::drawCell qtableview.cpp 929
10 QTableView::paintEvent qtableview.cpp 1419
11 QWidget::event qwidget.cpp 8775
12 QFrame::event qframe.cpp 557
13 QAbstractItemView::viewportEvent qabstractitemview.cpp 1644
14 QCoreApplicationPrivate::sendThroughObjectEventFil ters qcoreapplication.cpp 1065
15 QApplicationPrivate::notify_helper qapplication.cpp 4566
16 QApplication::notify qapplication.cpp 4356
17 QCoreApplication::notifyInternal qcoreapplication.cpp 955
18 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 234
19 QWidgetPrivate::drawWidget qwidget.cpp 5599
20 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
21 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
22 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
23 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
24 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
25 QWidgetPrivate::drawWidget qwidget.cpp 5652
26 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
27 QWidgetPrivate::drawWidget qwidget.cpp 5652
28 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
29 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
30 QWidgetPrivate::drawWidget qwidget.cpp 5652
31 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
32 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
33 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
34 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
35 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
36 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
37 QWidgetPrivate::drawWidget qwidget.cpp 5652
38 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
39 QWidgetPrivate::drawWidget qwidget.cpp 5652
40 QWidgetBackingStore::sync qbackingstore.cpp 1373
41 QWidgetBackingStore::sync qbackingstore.cpp 1161
42 QWidgetPrivate::syncBackingStore qwidget.cpp 1903
43 QETWidget::translatePaintEvent qapplication_x11.cpp 5277
44 QApplication::x11ProcessEvent qapplication_x11.cpp 3574
45 x11EventSourceDispatch qguieventdispatcher_glib.cpp 146
46 g_main_dispatch gmain.c 3203
47 g_main_context_dispatch gmain.c 3856
48 g_main_context_iterate gmain.c 3929
49 g_main_context_iteration gmain.c 3990
50 QEventDispatcherGlib::processEvents qeventdispatcher_glib.cpp 425
51 QGuiEventDispatcherGlib::processEvents qguieventdispatcher_glib.cpp 204
52 QEventLoop::processEvents qeventloop.cpp 149
53 QEventLoop::exec qeventloop.cpp 204
54 QCoreApplication::exec qcoreapplication.cpp
55 main main.cpp
And in the program output, i get: "free(): invalid pointer: 0x00007fffffffb518". I use a QList private data member in the model to store the data from the file, maybe it has something to do with this?, but again, i tried to not load data from the file, and just give numbers from the model, maybe i'm doing something wrong, i will keep checking...

Thank you for your answers!

d_stranz
30th January 2017, 20:25
It might help if you actually posted some code instead of just stack dumps, and reduced your code to something that reproduces the problem.


I use a QList private data member in the model to store the data from the file, maybe it has something to do with this?

I'd say that was a pretty good bet.

lugarci2
31st January 2017, 18:05
I've found the problem, a really silly thing, i didn't return an invalid QVariant in the data() function of the model if it was another role different than DisplayRole. But i wonder why it worked fine in 32 bits... :confused:



QVariant TableModel::data(const QModelIndex &index, int role) const {
if (role == Qt::DisplayRole){
...
}
return QVariant(); //I missed this
}


Anyway, again, thanks for your answers!

Lesiok
1st February 2017, 06:59
Strange compiler settings - should be an error message.

anda_skoa
1st February 2017, 09:20
I've found the problem, a really silly thing, i didn't return an invalid QVariant in the data() function of the model if it was another role different than DisplayRole.

Ah, yes, that was at least one obvious error when you said you are seeing checkboxes.

Cheers,
_

lugarci2
1st February 2017, 14:11
Strange compiler settings - should be an error message.

Mmmm, i have gcc default, and qmake with these arguments: "-r -spec linux-g++-64 CONFIG+=debug", also default.