avoid crash in MonitorPrivate::emitItemsNotification accessing empty list
Needs RevisionPublic

Authored by mkoller on Aug 3 2018, 6:19 PM.

Details

Reviewers
dvratil
Summary

It seems b3b61aaff4217c5942819f7848136c861a0f501a introduced a problem by accessing an empty list with first()
Attached patch fixes that, although I don't know if the logic is correct and the function should return false in this case.

Diff Detail

Repository
R165 Akonadi
Lint
Lint Skipped
Unit
Unit Tests Skipped
mkoller created this revision.Aug 3 2018, 6:19 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptAug 3 2018, 6:19 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
mkoller requested review of this revision.Aug 3 2018, 6:19 PM

I also reported this problem before at https://bugs.kde.org/show_bug.cgi?id=397131

dvratil requested changes to this revision.Aug 4 2018, 10:33 AM

This is not the right place for the fix. The problem is either in the Monitor (somewhere between the point where notification enters the system and where it crashes Monitor somehow loses Items from the notification) or in the Akonadi Server (which emits notifications without Items which is wrong because such notification makes no sense and should not have happened in the first place).

According to the backtrace in the bug, the offending notification was an ItemAdded notification, so let's see if we can find where that came from.

This revision now requires changes to proceed.Aug 4 2018, 10:33 AM
winterz added a subscriber: winterz.Aug 6 2018, 1:49 PM

I would appreciate a quick resolution to this crash or at least a temporary commit of Martin's patch.
In the meantime I will commit locally so kontact doesn't crash every time I send an email.

dvratil added a comment.EditedAug 6 2018, 7:30 PM

@winterz, @mkoller can you check if the application crash is preceded by FetchHelper requested from within a transaction, aborting, since this would deadlock! message from the Akonadi Server in terminal?

This is what I get (without my patch) when hitting "check for mails" in kmail:

20180807 15:13:21.422 CEST akonadiserver: New notification connection (registered as Akonadi::Server::NotificationSubscriber(0x7fc86c256620) )
20180807 15:13:21.425 CEST akonadi_airsyncdownload_resource_1: "2018-08-07T15:13:21" sent ...
20180807 15:13:21.450 CEST akonadiserver: Subscriber Akonadi::Server::NotificationSubscriber(0x7fc86c256620) identified as "SpecialCollectionsMonitor - 34097472"
20180807 15:13:21.462 CEST akonadiserver: only display
20180807 15:13:23.503 CEST akonadi_maildispatcher_agent: ASSERT: "!isEmpty()" in file /usr/include/qt5/QtCore/qvector.h, line 237
KCrash: Application 'akonadi_maildispatcher_agent' crashing...
KCrash: Attempting to start /usr/lib64/libexec/drkonqi from kdeinit
sock_file=/run/user/1000/kdeinit50
20180807 15:13:23.510 CEST akonadi_pop3_resource_3: ASSERT: "!isEmpty()" in file /usr/include/qt5/QtCore/qvector.h, line 237
KCrash: Application 'akonadi_pop3_resource' crashing...
KCrash: Attempting to start /usr/lib64/libexec/drkonqi from kdeinit
sock_file=/run/user/1000/kdeinit5
0
20180807 15:13:23.533 CEST akonadiserver: Subscriber "MessageListTagCacheMonitor - 159607920" disconnected
20180807 15:13:23.533 CEST akonadiserver: Shutting down "kmail2-182605794-SearchSession" ...
20180807 15:13:23.534 CEST akonadiserver: Subscriber "FilterManagerTagMonitor - 89852432" disconnected
20180807 15:13:23.534 CEST akonadiserver: Subscriber "TagActionManagerMonitor - 41244992" disconnected
20180807 15:13:23.534 CEST akonadiserver: Subscriber "MessageViewerMonitor - 41657344" disconnected
20180807 15:13:23.534 CEST akonadiserver: Subscriber "MessageListTagMonitor - 41457536" disconnected
20180807 15:13:23.534 CEST akonadiserver: Shutting down "MessageViewer-41656784" ...
20180807 15:13:23.534 CEST akonadiserver: Subscriber "SpecialCollectionsMonitor - 40987248" disconnected
20180807 15:13:23.535 CEST akonadiserver: Subscriber "KMail Kernel ETM - 38469360" disconnected
20180807 15:13:23.536 CEST akonadiserver: Shutting down "KMail Kernel ETM" ...
20180807 15:13:23.537 CEST akonadiserver: Shutting down "kmail2-182605794" ...
20180807 15:13:23.544 CEST akonadiserver: New notification connection (registered as Akonadi::Server::NotificationSubscriber(0x7fc86c23bd10) )
20180807 15:13:23.545 CEST akonadiserver: Subscriber Akonadi::Server::NotificationSubscriber(0x7fc86c23bd10) identified as "SpecialCollectionsMonitor - 27662752"

I have fixed this in commit f8fc30bac58da423038906fe86cd00393df14bb9 , it will be present in 18.08 release.