• Martin Heistermann's avatar
    Fix crash on window close event. · 05f49233
    Martin Heistermann authored
    Likely made visible by Qt 5.11, but was was broken before.
    
    Due to a direct qt connection, the CoreWidget is being destroyed while
    a) a CoreWidget method is on the stack
    b) the close event is not fully handled yet.
    
    Valgrind output for reference:
    
    ==6374== Invalid read of size 8
    ==6374==    at 0x71C64A1: QWindow::destroy() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.11.2)
    ==6374==    by 0x71C70DE: QWindow::event(QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.11.2)
    ==6374==    by 0x6C02F37: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BA7490: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BAEACF: QApplication::notify(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x7893038: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2)
    ==6374==    by 0x71B7DB9: QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.11.2)
    ==6374==    by 0x71BCA54: QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.11.2)
    ==6374==    by 0x7196D8A: QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.11.2)
    ==6374==    by 0xCA5685A: ??? (in /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5.11.2)
    ==6374==    by 0x7891D0A: QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2)
    ==6374==    by 0x7899E81: QCoreApplication::exec() (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2)
    ==6374==    by 0x33C6F2: main (OpenFlipper.cc:802)
    ==6374==  Address 0xc5fc6e8 is 8 bytes inside a block of size 88 free'd
    ==6374==    at 0x4836EEB: operator delete(void*) (vg_replace_malloc.c:576)
    ==6374==    by 0x6BD4CAA: QWidgetPrivate::deleteTLSysExtra() (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BD97D7: QWidget::destroy(bool, bool) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BE10E1: QWidget::~QWidget() (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x438381: CoreWidget::~CoreWidget() (CoreWidget.cc:658)
    ==6374==    by 0x4383A5: CoreWidget::~CoreWidget() (CoreWidget.cc:660)
    ==6374==    by 0x382D4C: Core::slotExit() (Core.cc:1219)
    ==6374==    by 0x504948: Core::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (moc_Core.cpp:1559)
    ==6374==    by 0x78BC28A: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2)
    ==6374==    by 0x515DFC: CoreWidget::exit() (moc_CoreWidget.cpp:1602)
    ==6374==    by 0x439BA9: CoreWidget::closeEvent(QCloseEvent*) (CoreWidget.cc:912)
    ==6374==    by 0x6BE57C7: QWidget::event(QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6CEBED3: QMainWindow::event(QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x43A82F: CoreWidget::event(QEvent*) (CoreWidget.cc:1103)
    ==6374==    by 0x6BA7490: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BAEACF: QApplication::notify(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x7893038: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2)
    ==6374==    by 0x6BE0CC0: QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BFFD1D: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6C02F2C: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BA7490: QApplicationPrivate::notify_helper(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x6BAEACF: QApplication::notify(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.11.2)
    ==6374==    by 0x7893038: QCoreApplication::notifyInternal2(QObject*, QEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2)
    ==6374==    by 0x71B7DB9: QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.11.2)
    05f49233
Core.cc 78.9 KB