Results 1 to 9 of 9

Thread: Program crashes at QApplication::exec()

  1. #1
    Join Date
    Oct 2016
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Program crashes at QApplication::exec()

    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...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    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,
    _

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Oct 2016
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    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):

    Qt Code:
    1. 1 __GI_raise raise.c 58
    2. 2 __GI_abort abort.c 89
    3. 3 __libc_message libc_fatal.c 175
    4. 4 malloc_printerr malloc.c 5046
    5. 5 _int_free malloc.c 3902
    6. 6 clear qvariant.cpp 291
    7. 7 QStyledItemDelegate::initStyleOption qstyleditemdelegate.cpp 333
    8. 8 QStyledItemDelegate::paint qstyleditemdelegate.cpp 425
    9. 9 QTableViewPrivate::drawCell qtableview.cpp 929
    10. 10 QTableView::paintEvent qtableview.cpp 1419
    11. 11 QWidget::event qwidget.cpp 8775
    12. 12 QFrame::event qframe.cpp 557
    13. 13 QAbstractItemView::viewportEvent qabstractitemview.cpp 1644
    14. 14 QCoreApplicationPrivate::sendThroughObjectEventFilters qcoreapplication.cpp 1065
    15. 15 QApplicationPrivate::notify_helper qapplication.cpp 4566
    16. 16 QApplication::notify qapplication.cpp 4356
    17. 17 QCoreApplication::notifyInternal qcoreapplication.cpp 955
    18. 18 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 234
    19. 19 QWidgetPrivate::drawWidget qwidget.cpp 5599
    20. 20 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
    21. 21 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    22. 22 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    23. 23 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    24. 24 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    25. 25 QWidgetPrivate::drawWidget qwidget.cpp 5652
    26. 26 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
    27. 27 QWidgetPrivate::drawWidget qwidget.cpp 5652
    28. 28 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
    29. 29 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    30. 30 QWidgetPrivate::drawWidget qwidget.cpp 5652
    31. 31 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
    32. 32 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    33. 33 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    34. 34 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    35. 35 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    36. 36 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5795
    37. 37 QWidgetPrivate::drawWidget qwidget.cpp 5652
    38. 38 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5808
    39. 39 QWidgetPrivate::drawWidget qwidget.cpp 5652
    40. 40 QWidgetBackingStore::sync qbackingstore.cpp 1373
    41. 41 QWidgetBackingStore::sync qbackingstore.cpp 1161
    42. 42 QWidgetPrivate::syncBackingStore qwidget.cpp 1903
    43. 43 QETWidget::translatePaintEvent qapplication_x11.cpp 5277
    44. 44 QApplication::x11ProcessEvent qapplication_x11.cpp 3574
    45. 45 x11EventSourceDispatch qguieventdispatcher_glib.cpp 146
    46. 46 g_main_dispatch gmain.c 3203
    47. 47 g_main_context_dispatch gmain.c 3856
    48. 48 g_main_context_iterate gmain.c 3929
    49. 49 g_main_context_iteration gmain.c 3990
    50. 50 QEventDispatcherGlib::processEvents qeventdispatcher_glib.cpp 425
    51. 51 QGuiEventDispatcherGlib::processEvents qguieventdispatcher_glib.cpp 204
    52. 52 QEventLoop::processEvents qeventloop.cpp 149
    53. 53 QEventLoop::exec qeventloop.cpp 204
    54. 54 QCoreApplication::exec qcoreapplication.cpp
    55. 55 main main.cpp
    To copy to clipboard, switch view to plain text mode 
    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!
    Last edited by lugarci2; 30th January 2017 at 20:49.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Program crashes at QApplication::exec()

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. #6
    Join Date
    Oct 2016
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    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...

    Qt Code:
    1. QVariant TableModel::data(const QModelIndex &index, int role) const {
    2. if (role == Qt::DisplayRole){
    3. ...
    4. }
    5. return QVariant(); //I missed this
    6. }
    To copy to clipboard, switch view to plain text mode 

    Anyway, again, thanks for your answers!

  7. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    Strange compiler settings - should be an error message.

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    Quote Originally Posted by lugarci2 View Post
    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,
    _

  9. #9
    Join Date
    Oct 2016
    Posts
    6
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes at QApplication::exec()

    Quote Originally Posted by Lesiok View Post
    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.

Similar Threads

  1. Crash on QApplication::exec()
    By Nivek in forum Qt Programming
    Replies: 13
    Last Post: 6th April 2011, 23:18
  2. QThread::exec and QApplication instantiation
    By Ray Froehlich in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2010, 06:35
  3. Replies: 4
    Last Post: 1st December 2008, 12:13
  4. Quitting before the QApplication::exec()
    By jsmax in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2008, 21:19
  5. Replies: 2
    Last Post: 16th March 2007, 10:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.