D19559: Explicitly delete MailWebEnginePage to avoid crash on KMail exit or viewer window close
Jonathan Marten
noreply at phabricator.kde.org
Wed Mar 6 09:59:20 GMT 2019
marten created this revision.
marten added a reviewer: KDE PIM.
Herald added a project: KDE PIM.
Herald added a subscriber: kde-pim.
marten requested review of this revision.
REVISION SUMMARY
The crash happens with both Qt 5.12 and 5.13, either on quitting KMail or closing a separate mail viewer window. The backtrace is several pages long, but the hopefully relevant parts are:
Application: KMail (kmail), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f68e493fd40 (LWP 4419))]
Thread 1 (Thread 0x7f68e493fd40 (LWP 4419)):
[KCrash Handler]
#7 0x00007f68d581e09a in QWebEnginePagePrivate::bindPageAndWidget (page=0x0, widget=0x5620d4c1c200) at /var/tmp/portage/dev-qt/qtwebengine-5.12.9999/work/qtwebengine-5.12.9999/src/webenginewidgets/api/qwebenginepage.h:358
#8 0x00007f68d582fa91 in QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget::~RenderWidgetHostViewQtDelegateWidget (this=0x5620d4c1c200, __in_chrg=<optimized out>) at /var/tmp/portage/dev-qt/qtwebengine-5.12.9999/work/qtwebengine-5.12.9999/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp:174
...
#31 QWebEnginePagePrivate::~QWebEnginePagePrivate (this=<optimized out>, __in_chrg=<optimized out>) at /var/tmp/portage/dev-qt/qtwebengine-5.12.9999/work/qtwebengine-5.12.9999/src/webenginewidgets/api/qwebenginepage.cpp:263
#32 0x00007f68d58241a9 in QWebEnginePagePrivate::~QWebEnginePagePrivate (this=0x5620d4a6d530, __in_chrg=<optimized out>) at /var/tmp/portage/dev-qt/qtwebengine-5.12.9999/work/qtwebengine-5.12.9999/src/webenginewidgets/api/qwebenginepage.cpp:263
#33 0x00007f68d581adca in QWebEnginePagePrivate::releaseProfile (this=0x5620d4a6d530) at /usr/include/qt5/QtCore/qscopedpointer.h:162
#34 0x00007f68ce4bc61e in QtWebEngineCore::ProfileAdapter::~ProfileAdapter (this=0x5620d4abc080, __in_chrg=<optimized out>) at /usr/include/qt5/QtCore/qarraydata.h:211
...
#41 0x00007f68d5826b69 in QWebEngineProfile::~QWebEngineProfile (this=0x5620d4a950c0, __in_chrg=<optimized out>) at /var/tmp/portage/dev-qt/qtwebengine-5.12.9999/work/qtwebengine-5.12.9999/src/webenginewidgets/api/qwebengineprofile.cpp:321
#42 0x00007f68de8b4ef4 in QObjectPrivate::deleteChildren() () at /var/tmp/portage/dev-qt/qtcore-5.12.9999/work/qtcore-5.12.9999/src/corelib/kernel/qobject.cpp:2010
#43 0x00007f68df6ac706 in QWidget::~QWidget() () at /var/tmp/portage/dev-qt/qtwidgets-5.12.9999/work/qtwidgets-5.12.9999/src/widgets/kernel/qwidget.cpp:1703
#44 0x00007f68db62a389 in MessageViewer::MailWebEngineView::~MailWebEngineView (this=0x5620d4aaea00, __in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/webengine/mailwebengineview.cpp:120
#45 0x00007f68db5c9754 in MessageViewer::ViewerPrivate::~ViewerPrivate (this=0x5620d492a900, __in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/viewer_p.cpp:261
#46 0x00007f68db5c98c9 in MessageViewer::ViewerPrivate::~ViewerPrivate (this=0x5620d492a900, __in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/viewer_p.cpp:256
#47 0x00007f68de8b4ef4 in QObjectPrivate::deleteChildren() () at /var/tmp/portage/dev-qt/qtcore-5.12.9999/work/qtcore-5.12.9999/src/corelib/kernel/qobject.cpp:2010
#48 0x00007f68df6ac706 in QWidget::~QWidget() () at /var/tmp/portage/dev-qt/qtwidgets-5.12.9999/work/qtwidgets-5.12.9999/src/widgets/kernel/qwidget.cpp:1703
#49 0x00007f68db5bc9a9 in MessageViewer::Viewer::~Viewer (this=0x5620d4af8f40, __in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/viewer.cpp:84
An ominous debug message is also printed just before the crash, by QWebEnginePagePrivate::releaseProfile() in ./src/webenginewidgets/api/qwebenginepage.cpp:
kmail/default unknown: Release of profile requested but WebEnginePage still not deleted. Expect troubles !
I haven't been able to resolve the root cause of this, but there is a clue in the above message and in the QWebEnginePage API documentation:
"If the profile is not the default profile, the caller must ensure that the profile stays alive for as long as the page does."
The fix appears to be to explicitly delete the MailWebEnginePage in the MailWebEngineView destructor, so that the page is deleted before the profile (as a child of the MailWebEngineView) is deleted.
TEST PLAN
Built messagelib with this change, observed no crash when quitting KMail or closing a message viewer window. Without this change, the crash happens every time.
REPOSITORY
R94 PIM: Message Library
REVISION DETAIL
https://phabricator.kde.org/D19559
AFFECTED FILES
messageviewer/src/viewer/webengine/mailwebengineview.cpp
To: marten, #kde_pim
Cc: kde-pim, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20190306/b3d7ed36/attachment.html>
More information about the kde-pim
mailing list