Fix crash on selecting items in documentation plugins' home listings
ClosedPublic

Authored by kossebau on Jul 6 2017, 2:29 PM.

Details

Summary

The home listing widget of e.g. QtHelp and man documentation plugins is
done with a QTreeView, handling the QTreeView::clicked signal by
synchronously providing a new StandardDocumentationView instance
to the viewer. The viewer then drops the current widget
(thus the QTreeView), but with a deleterLater(), so e.g. the still
on-going mousereleaseevent handler will not get into trouble.
That good intention though is screwed over during setting up the
new documentation page, still in sync processing, when setting
a new custom QWebEnginePage:
that results in destruction of the default one, which deep down
in the destruction process inside ~QQuickRenderControl() results
in some nested event loop. Which then also results in deletion
of our QTreeView instance already. So when execution finally
returns to the mousereleaseevent handler to continue... -> boom

Patch fixes this by setting the custom QWebEnginePage on setup,
so no default instance is created (happens on first access to
page()) and thus also no destructor is called.
The delegation policy is controlled by keeping a pointer to the
custom page and flipping the delegation flag as needed.

Diff Detail

Repository
R33 KDevPlatform
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Jul 6 2017, 2:29 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJul 6 2017, 2:29 PM

Backtrace of actual crash:

#1  0x00007ffff1deb939 in QAbstractItemView::mouseReleaseEvent(QMouseEvent*) () at /usr/lib64/libQt5Widgets.so.5
#2  0x00007ffff1e3007b in QTreeView::mouseReleaseEvent(QMouseEvent*) () at /usr/lib64/libQt5Widgets.so.5
#3  0x00007ffff1bf9748 in QWidget::event(QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#4  0x00007ffff1cd24ee in QFrame::event(QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#5  0x00007ffff1df3f2c in QAbstractItemView::viewportEvent(QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#6  0x00007ffff1e2f96c in QTreeView::viewportEvent(QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#7  0x00007ffff0e32284 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /usr/lib64/libQt5Core.so.5
#8  0x00007ffff1bbb915 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#9  0x00007ffff1bc320f in QApplication::notify(QObject*, QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#10 0x00007ffff0e32578 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib64/libQt5Core.so.5
#11 0x00007ffff1bc225f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()

Backtrace of premature destruction of the man home widget , with the QTreeView as child:

#5  0x00007fff92729b4a in ManPageDocumentationWidget::~ManPageDocumentationWidget() (this=0x29447d0, __in_chrg=<optimized out>)
    at /home/koder/Kode/kdegit/kf5/extragear/kdevelop/kdevelop/documentation/manpage/manpagedocumentationwidget.cpp:74
#6  0x00007ffff0e5ff88 in QObject::event(QEvent*) () at /usr/lib64/libQt5Core.so.5
#7  0x00007ffff1bf9ed3 in QWidget::event(QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#8  0x00007ffff1cd24ee in QFrame::event(QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#9  0x00007ffff1bbb93c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#10 0x00007ffff1bc2cb4 in QApplication::notify(QObject*, QEvent*) () at /usr/lib64/libQt5Widgets.so.5
#11 0x00007ffff0e32578 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib64/libQt5Core.so.5
#12 0x00007ffff0e348b5 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib64/libQt5Core.so.5
#13 0x00007fffeae088bd in  () at /usr/lib64/libQt5Quick.so.5
#14 0x00007fffeae08bd0 in QQuickRenderControl::~QQuickRenderControl() () at /usr/lib64/libQt5Quick.so.5
#15 0x00007fffe693f023 in  () at /usr/lib64/libQt5QuickWidgets.so.5
#16 0x00007fffe693da9b in  () at /usr/lib64/libQt5QuickWidgets.so.5
#17 0x00007fffe693db19 in  () at /usr/lib64/libQt5QuickWidgets.so.5
#18 0x00007ffff0e666f3 in QObject::~QObject() () at /usr/lib64/libQt5Core.so.5
#19 0x00007ffff1bf5826 in QWidget::~QWidget() () at /usr/lib64/libQt5Widgets.so.5
#20 0x00007fffe62a5021 in  () at /usr/lib64/libQt5WebEngineWidgets.so.5
#21 0x00007fffdff3210a in  () at /usr/lib64/libQt5WebEngineCore.so.5
#22 0x00007fffdff32279 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#23 0x00007fffe03912bf in  () at /usr/lib64/libQt5WebEngineCore.so.5
#24 0x00007fffe0386022 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#25 0x00007fffe01e1379 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#26 0x00007fffe020dd3f in  () at /usr/lib64/libQt5WebEngineCore.so.5
#27 0x00007fffe020e329 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#28 0x00007fffe021457d in  () at /usr/lib64/libQt5WebEngineCore.so.5
#29 0x00007fffe01e3d21 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#30 0x00007fffe01ded9a in  () at /usr/lib64/libQt5WebEngineCore.so.5
#31 0x00007fffe0455f06 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#32 0x00007fffe04561c9 in  () at /usr/lib64/libQt5WebEngineCore.so.5
#33 0x00007fffdff4d9de in  () at /usr/lib64/libQt5WebEngineCore.so.5
#34 0x00007fffdff4dc7a in QtWebEngineCore::WebContentsAdapter::~WebContentsAdapter() () at /usr/lib64/libQt5WebEngineCore.so.5
#35 0x00007fffe6295af2 in  () at /usr/lib64/libQt5WebEngineWidgets.so.5
#36 0x00007fffe6295b49 in  () at /usr/lib64/libQt5WebEngineWidgets.so.5
#37 0x00007fffe6290203 in QWebEnginePage::~QWebEnginePage() () at /usr/lib64/libQt5WebEngineWidgets.so.5
#38 0x00007fffe6290229 in QWebEnginePage::~QWebEnginePage() () at /usr/lib64/libQt5WebEngineWidgets.so.5
#39 0x00007fffe62a1352 in  () at /usr/lib64/libQt5WebEngineWidgets.so.5
#40 0x00007fffedcd227c in KDevelop::StandardDocumentationView::setDelegateLinks(bool) (this=0x4aaa000, delegate=true)
kfunk accepted this revision.Jul 6 2017, 2:58 PM
kfunk added a subscriber: kfunk.

Can't spot anything wrong, thanks!

documentation/standarddocumentationview.cpp
78 ↗(On Diff #16237)

Init here?

This revision is now accepted and ready to land.Jul 6 2017, 2:58 PM
This revision was automatically updated to reflect the committed changes.
kossebau marked an inline comment as done.