Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.9.1
-
None
-
Ubuntu 17.04, Qt 5.9.1 (built from source)
-
47e2c461d517a6bb2fe663f752f3c7dd72c63357
Description
I have an application that uses a QML Map item inside of a QQuickWidget. That QQuickWidget is located in a QTabWidget, so the pane that contains it is sometimes hidden. In some rare, hard-to-duplicate situations, I've observed crashes when the pane containing the Map transitions from hidden to shown. I'm using the Mapbox GL plugin, and the Map also contains several MapItem instances as children, including MapPolyline and MapQuickItem items.
The crash is due to an unhandled exception; when the view is shown, the plugin is told to update its scene graph node (in `QDeclarativeGeoMap::updatePaintNode()`). A few layers down, this results in a call to `QMapboxGL::removeLayer()` with a layer name that doesn't exist. The underlying Mapbox GL library throws a `std::runtime_error` when this occurs, an exception that isn't caught by the Mapbox GL plugin, so it percolates up the stack, where it isn't handled anywhere, and the application terminates.
I found that if I add a try/catch block around the call in `QMapboxGL::removeLayer()`, then it appears to make the crash go away; there doesn't seem to be any other ill effects to the failure to remove the layer. It seems that, when interacting with a third-party API that can emit exceptions, the Qt plugin should make sure to catch those exceptions to avoid uncontrollable application termination like this one. There may be other places in the Mapbox GL API where this could occur; I would recommend scrubbing the Qt wrapper to ensure there isn't any more exception leakage as well.
Here is a stack trace taken when the error occurs:
terminate called after throwing an instance of 'std::runtime_error' what(): no such layer Thread 1 "app" received signal SIGABRT, Aborted. __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58 58 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 0x00007ffff35c677f in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58 #1 0x00007ffff35c837a in __GI_abort () at abort.c:89 #2 0x00007ffff3c0056d in __gnu_cxx::__verbose_terminate_handler() () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff3bfe316 in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007ffff3bfe361 in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff3bfe579 in () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007fffb90a85dc in () at /opt/qt/5.9.1/plugins/geoservices/libqtgeoservices_mapboxgl.so #7 0x00007fffb8fe97da in () at /opt/qt/5.9.1/plugins/geoservices/libqtgeoservices_mapboxgl.so #8 0x00007fffb8fa250e in QMapboxGL::removeLayer(QString const&) () at /opt/qt/5.9.1/plugins/geoservices/libqtgeoservices_mapboxgl.so #9 0x00007fffb8f93a03 in () at /opt/qt/5.9.1/plugins/geoservices/libqtgeoservices_mapboxgl.so #10 0x00007fffb8f93d8a in () at /opt/qt/5.9.1/plugins/geoservices/libqtgeoservices_mapboxgl.so #11 0x00007fffe40869d2 in QDeclarativeGeoMap::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) () at /opt/qt/5.9.1/lib/libQt5Location.so.5 #12 0x00007fffe3d4ccf8 in QQuickWindowPrivate::updateDirtyNode(QQuickItem*) () at /opt/qt/5.9.1/lib/libQt5Quick.so.5 #13 0x00007fffe3d4d36f in QQuickWindowPrivate::updateDirtyNodes() () at /opt/qt/5.9.1/lib/libQt5Quick.so.5 #14 0x00007fffe3d4e48a in QQuickWindowPrivate::syncSceneGraph() () at /opt/qt/5.9.1/lib/libQt5Quick.so.5 #15 0x00007fffe3e08699 in QQuickRenderControl::sync() () at /opt/qt/5.9.1/lib/libQt5Quick.so.5 #16 0x00007ffff7fe87b0 in () at /opt/qt/5.9.1/lib/libQt5QuickWidgets.so.5 #17 0x00007ffff7fe9d99 in QQuickWidget::showEvent(QShowEvent*) () at /opt/qt/5.9.1/lib/libQt5QuickWidgets.so.5 #18 0x00007ffff4e0b620 in QWidget::event(QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #19 0x00007ffff4dca0dc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #20 0x00007ffff4dd19e1 in QApplication::notify(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #21 0x00007ffff43b59c0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #22 0x00007ffff4e08398 in QWidgetPrivate::show_helper() () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #23 0x00007ffff4e082d7 in QWidgetPrivate::showChildren(bool) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #24 0x00007ffff4e0836f in QWidgetPrivate::show_helper() () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #25 0x00007ffff4e082d7 in QWidgetPrivate::showChildren(bool) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #26 0x00007ffff4e0836f in QWidgetPrivate::show_helper() () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #27 0x00007ffff4e0b165 in QWidget::setVisible(bool) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #28 0x00007ffff4dece25 in QStackedLayout::setCurrentIndex(int) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #29 0x00007ffff4f541ff in () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #30 0x00007ffff4f56247 in () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #31 0x00007ffff43e2cb7 in QMetaObject::activate(QObject*, int, int, void**) () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #32 0x00007ffff4f4900e in QTabBar::currentChanged(int) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #33 0x00007ffff4f4d7b5 in QTabBar::setCurrentIndex(int) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #34 0x00007ffff4f4ff20 in QTabBar::mousePressEvent(QMouseEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #35 0x00007ffff4e0beef in QWidget::event(QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #36 0x00007ffff4f4e363 in QTabBar::event(QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #37 0x00007ffff4dca0dc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #38 0x00007ffff4dd2848 in QApplication::notify(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #39 0x00007ffff43b59c0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #40 0x00007ffff4dd0f4d in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #41 0x00007ffff4e253d6 in () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #42 0x00007ffff4e27db3 in () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #43 0x00007ffff4dca0dc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #44 0x00007ffff4dd19e1 in QApplication::notify(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Widgets.so.5 #45 0x00007ffff43b59c0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #46 0x00007ffff47f7d33 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /opt/qt/5.9.1/lib/libQt5Gui.so.5 #47 0x00007ffff47f98f5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () at /opt/qt/5.9.1/lib/libQt5Gui.so.5 #48 0x00007ffff47d416b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /opt/qt/5.9.1/lib/libQt5Gui.so.5 #49 0x00007fffd5c58c40 in () at /opt/qt/5.9.1/plugins/platforms/../../lib/libQt5XcbQpa.so.5 #50 0x00007fffed68d377 in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0 #51 0x00007fffed68d5e0 in () at /lib/x86_64-linux-gnu/libglib-2.0.so.0 #52 0x00007fffed68d68c in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0 #53 0x00007ffff440bb3f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #54 0x00007ffff43b3a0a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #55 0x00007ffff43bc9e4 in QCoreApplication::exec() () at /opt/qt/5.9.1/lib/libQt5Core.so.5 #56 0x000055555555c9d9 in main ()