Bug 435427

Summary: akonadi_imap_resource: segfault on authentication
Product: [Frameworks and Libraries] Akonadi Reporter: Victor MatarĂ© <vmatare+kdebug>
Component: IMAP resourceAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: fmdefrancesco, thiago.bauermann
Priority: NOR Keywords: drkonqi
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In: 23.04.1
Attachments: New crash information added by DrKonqi

Description Victor Mataré 2021-04-06 14:45:46 UTC
Application: akonadi_imap_resource (5.15.3 (20.08.3))

Qt Version: 5.15.2
Frameworks Version: 5.79.0
Operating System: Linux 5.11.11-200.fc33.x86_64 x86_64
Windowing system: X11
Distribution: "Fedora release 33 (Thirty Three)"

-- Information about the crash:
The resource was working fine before and then it suddenly started crashing. Nothing really changed except that a few new emails came in. The server is a Microsoft 365 Exchange mailbox. I'll try to sort through the new emails, maybe I can identify the culprit.

The crash can be reproduced every time.

-- Backtrace:
Application: support (akonadi_imap_resource), signal: Segmentation fault

[KCrash Handler]
#4  ImapAccount::authenticationMode (this=0x0) at /usr/src/debug/kdepim-runtime-20.08.3-1.fc33.x86_64/resources/imap/imapaccount.cpp:85
#5  0x0000560dd7904a8a in SessionPool::requestPassword (this=0x560dd8f979d0) at /usr/src/debug/kdepim-runtime-20.08.3-1.fc33.x86_64/resources/imap/sessionpool.cpp:88
#6  0x00007fc12f6a0d1e in QObject::event(QEvent*) () from /lib64/libQt5Core.so.5
#7  0x00007fc1302a6ec3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQt5Widgets.so.5
#8  0x00007fc12f678bd8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib64/libQt5Core.so.5
#9  0x00007fc12f67b8c7 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /lib64/libQt5Core.so.5
#10 0x00007fc12f6c5c27 in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /lib64/libQt5Core.so.5
#11 0x00007fc12d870a9f in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#12 0x00007fc12d8c2a98 in g_main_context_iterate.constprop () from /lib64/libglib-2.0.so.0
#13 0x00007fc12d86de73 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#14 0x00007fc12f6c56f3 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#15 0x00007fc12f67757b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#16 0x00007fc12f67f1b4 in QCoreApplication::exec() () from /lib64/libQt5Core.so.5
#17 0x0000560dd78b5157 in Akonadi::ResourceBase::init<ImapResource> (argc=<optimized out>, argv=0x7ffdffff99d0) at /usr/include/KF5/AkonadiAgentBase/resourcebase.h:186
#18 0x00007fc12f0511e2 in __libc_start_main () from /lib64/libc.so.6
#19 0x0000560dd78b306e in _start ()
[Inferior 1 (process 80660) detached]

Possible duplicates by query: bug 435332, bug 434873, bug 434725, bug 434294, bug 434282.

Reported using DrKonqi
Comment 1 Thiago Jung Bauermann 2021-04-09 17:57:51 UTC
Created attachment 137453 [details]
New crash information added by DrKonqi

akonadi_kolab_resource (5.15.1 (20.08.1)) using Qt 5.14.2

- What I was doing when the application crashed:

I wasn't doing anything related to KMail or Akonadi. This just happens by itself (during periodic mail check, I would assume).
It has happened a couple of times. This last time the machine was idle for a while and it went to sleep. When I came back to it, there was this crash. On the first time, I don't remember if it was a similar situation.

-- Backtrace (Reduced):
#4  ImapAccount::authenticationMode() const (this=0x0) at ./resources/imap/imapaccount.cpp:85
#5  0x000056006d9402fa in SessionPool::requestPassword() (this=0x56006f0f0600) at ./resources/imap/sessionpool.cpp:88
#6  0x00007f4edb561651 in QObject::event(QEvent*) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f4edc4e1013 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#8  0x00007f4edb5351ca in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
Comment 2 Victor Mataré 2021-04-10 18:42:35 UTC
This has become an intermittently recurring problem now for one particular account I have. It's not linked to anything visibly happening on the server, i.e. it's not triggered by particular emails. It'll simply start at some (apparently random) point, then the resource will go into a crash loop (sometimes for hours) and after a while it will start working again (again for no apparent reason).

Strangely, another account I have with the exact same settings on the same server is working fine.
Comment 3 Thiago Jung Bauermann 2021-04-26 22:40:57 UTC
This crash just happened again, with the exact same backtrace. The last time it happened was when I added my previous comment to this bug.

Again, the machine was idle for a long while (about 1h30m), but it didn't go to sleep this time. The common factor seems to be the machine being idle for a while. Perhaps there's a bug when periodic mail check is triggered while the screensaver is active?
Comment 4 Bug Janitor Service 2023-04-27 18:48:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/pim/kdepim-runtime/-/merge_requests/109
Comment 5 Carl Schwan 2023-04-27 18:57:59 UTC
*** Bug 453092 has been marked as a duplicate of this bug. ***
Comment 6 Christophe Marin 2023-04-29 08:58:53 UTC
Git commit 8344e0cc25d71267e684bf03d658b7f9d05b2d89 by Christophe Marin, on behalf of Carl Schwan.
Committed on 29/04/2023 at 08:49.
Pushed by krop into branch 'master'.

Fix crash trying to access password of empty account

The connect method of SessionPool discard the ImapAccount if it is not
empty the requestPassword method will try to fetch the password for the
empty account and this crash due to a null pointer dereference.

M  +1    -1    resources/imap/sessionpool.cpp

https://invent.kde.org/pim/kdepim-runtime/commit/8344e0cc25d71267e684bf03d658b7f9d05b2d89
Comment 7 Christophe Marin 2023-04-29 09:54:55 UTC
Git commit 9cfc0f6a5c53fc3c7dbe9d25ceea1f8ec1110d59 by Christophe Marin, on behalf of Carl Schwan.
Committed on 29/04/2023 at 09:54.
Pushed by krop into branch 'release/23.04'.

Fix crash trying to access password of empty account

The connect method of SessionPool discard the ImapAccount if it is not
empty the requestPassword method will try to fetch the password for the
empty account and this crash due to a null pointer dereference.
(cherry picked from commit 8344e0cc25d71267e684bf03d658b7f9d05b2d89)

M  +1    -1    resources/imap/sessionpool.cpp

https://invent.kde.org/pim/kdepim-runtime/commit/9cfc0f6a5c53fc3c7dbe9d25ceea1f8ec1110d59