<table><tr><td style="">marten created this revision.<br />marten added a reviewer: KDE PIM.<br />Herald added a project: KDE PIM.<br />Herald added a subscriber: kde-pim.<br />marten requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D19559">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>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:</p>
<p>Application: KMail (kmail), signal: Segmentation fault<br />
Using host libthread_db library "/lib64/libthread_db.so.1".<br />
[Current thread is 1 (Thread 0x7f68e493fd40 (LWP 4419))]</p>
<p>Thread 1 (Thread 0x7f68e493fd40 (LWP 4419)):<br />
[KCrash Handler]<br />
#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<br />
#8 0x00007f68d582fa91 in QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget::~RenderWidgetHostViewQtDelegateWidget (this=0x5620d4c1c200, <u>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<br />
...<br />
#31 QWebEnginePagePrivate::~QWebEnginePagePrivate (this=<optimized out>, </u>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<br />
#32 0x00007f68d58241a9 in QWebEnginePagePrivate::~QWebEnginePagePrivate (this=0x5620d4a6d530, <u>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<br />
#33 0x00007f68d581adca in QWebEnginePagePrivate::releaseProfile (this=0x5620d4a6d530) at /usr/include/qt5/QtCore/qscopedpointer.h:162<br />
#34 0x00007f68ce4bc61e in QtWebEngineCore::ProfileAdapter::~ProfileAdapter (this=0x5620d4abc080, </u>in_chrg=<optimized out>) at /usr/include/qt5/QtCore/qarraydata.h:211<br />
...<br />
#41 0x00007f68d5826b69 in QWebEngineProfile::~QWebEngineProfile (this=0x5620d4a950c0, <u>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<br />
#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<br />
#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<br />
#44 0x00007f68db62a389 in MessageViewer::MailWebEngineView::~MailWebEngineView (this=0x5620d4aaea00, </u>in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/webengine/mailwebengineview.cpp:120<br />
#45 0x00007f68db5c9754 in MessageViewer::ViewerPrivate::~ViewerPrivate (this=0x5620d492a900, <u>in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/viewer_p.cpp:261<br />
#46 0x00007f68db5c98c9 in MessageViewer::ViewerPrivate::~ViewerPrivate (this=0x5620d492a900, </u>in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/viewer_p.cpp:256<br />
#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<br />
#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<br />
#49 0x00007f68db5bc9a9 in MessageViewer::Viewer::~Viewer (this=0x5620d4af8f40, __in_chrg=<optimized out>) at messagelib/messageviewer/src/viewer/viewer.cpp:84</p>
<p>An ominous debug message is also printed just before the crash, by QWebEnginePagePrivate::releaseProfile() in ./src/webenginewidgets/api/qwebenginepage.cpp:</p>
<p>kmail/default unknown: Release of profile requested but WebEnginePage still not deleted. Expect troubles !</p>
<p>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:</p>
<p>"If the profile is not the default profile, the caller must ensure that the profile stays alive for as long as the page does."</p>
<p>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.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>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.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R94 PIM: Message Library</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D19559">https://phabricator.kde.org/D19559</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>messageviewer/src/viewer/webengine/mailwebengineview.cpp</div></div></div><br /><div><strong>To: </strong>marten, KDE PIM<br /><strong>Cc: </strong>kde-pim, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil<br /></div>