Bug 310887

Summary: Imap resource crashes randomly.
Product: [Frameworks and Libraries] Akonadi Reporter: Luis Silva <lacsilva>
Component: IMAP resourceAssignee: Christian Mollekopf <chrigi_1>
Status: RESOLVED FIXED    
Severity: crash CC: bosyber, chrigi_1, dvratil, kdepim-bugs, lacsilva, mollekopf, rserral, vkrause, wheel
Priority: NOR    
Version: GIT (master)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi

Description Luis Silva 2012-11-29 17:43:24 UTC
Application: akonadi_imap_resource (4.9)
KDE Platform Version: 4.9.3 (Compiled from sources)
Qt Version: 4.8.3
Operating System: Linux 3.5.0-18-generic i686
Distribution: Ubuntu 12.10

-- Information about the crash:
- What I was doing when the application crashed:
I started kmail and the imap resource crashed. This crash happens randomly and always for the same account. I can provide more information if required.

The crash can be reproduced some of the time.

-- Backtrace:
Application: IPGP of type IMAP E-Mail Server (akonadi_imap_resource), signal: Aborted
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0xb4a02740 (LWP 7767))]

Thread 3 (Thread 0xb20f6b40 (LWP 7836)):
#0  0xb77d8424 in __kernel_vsyscall ()
#1  0xb577a3eb in read () at ../sysdeps/unix/syscall-template.S:82
#2  0xb54f0f5e in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#3  0xb54b083b in g_main_context_check () from /lib/i386-linux-gnu/libglib-2.0.so.0
#4  0xb54b0c92 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#5  0xb54b0e61 in g_main_context_iteration () from /lib/i386-linux-gnu/libglib-2.0.so.0
#6  0xb738099f in QEventDispatcherGlib::processEvents (this=0xb1700468, flags=...) at kernel/qeventdispatcher_glib.cpp:426
#7  0xb734d26c in QEventLoop::processEvents (this=this@entry=0xb20f6238, flags=...) at kernel/qeventloop.cpp:149
#8  0xb734d561 in QEventLoop::exec (this=0xb20f6238, flags=...) at kernel/qeventloop.cpp:204
#9  0xb723866c in QThread::exec (this=0x8bae3d8) at thread/qthread.cpp:501
#10 0xb658319d in KIMAP::SessionThread::run (this=0x8bae3d8) at /home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/sessionthread.cpp:182
#11 0xb723ba58 in QThreadPrivate::start (arg=0x8bae3d8) at thread/qthread_unix.cpp:338
#12 0xb55ddd4c in start_thread (arg=0xb20f6b40) at pthread_create.c:308
#13 0xb578ad3e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

Thread 2 (Thread 0xb16ffb40 (LWP 8015)):
#0  0xb5568dcd in __GI_clock_gettime (clock_id=1, tp=0xb16fef88) at ../sysdeps/unix/clock_gettime.c:116
#1  0xb7299fb5 in do_gettime (frac=0xb16fef80, sec=0xb16fef78) at tools/qelapsedtimer_unix.cpp:123
#2  qt_gettime () at tools/qelapsedtimer_unix.cpp:140
#3  0xb738136e in QTimerInfoList::updateCurrentTime (this=0xb0d0323c) at kernel/qeventdispatcher_unix.cpp:343
#4  0x7fffffff in ?? ()
#5  0xb73816fa in QTimerInfoList::timerWait (this=0xb0d0323c, tm=...) at kernel/qeventdispatcher_unix.cpp:450
#6  0x7fffffff in ?? ()

Thread 1 (Thread 0xb4a02740 (LWP 7767)):
[KCrash Handler]
#7  0xb77d8424 in __kernel_vsyscall ()
#8  0xb56ca1df in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#9  0xb56cd825 in __GI_abort () at abort.c:91
#10 0xb723072c in qt_message_output (msgType=QtFatalMsg, buf=0x8acbe28 "ASSERT: \"!socketTimer.isActive()\" in file /home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp, line 462") at global/qglobal.cpp:2290
#11 0xb7230b39 in qt_message (msgType=QtFatalMsg, msg=0xb73ba598 "ASSERT: \"%s\" in file %s, line %d", ap=0xbf99fc84 "\213\266Y\266h\265Y\266\316\001") at global/qglobal.cpp:2336
#12 0xb7230c58 in qFatal (msg=msg@entry=0xb73ba598 "ASSERT: \"%s\" in file %s, line %d") at global/qglobal.cpp:2519
#13 0xb7230ce5 in qt_assert (assertion=0xb659b68b "!socketTimer.isActive()", file=0xb659b568 "/home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp", line=462) at global/qglobal.cpp:2016
#14 0xb657ed95 in KIMAP::SessionPrivate::startSocketTimer (this=this@entry=0x8b16370) at /home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp:462
#15 0xb6580851 in KIMAP::SessionPrivate::doStartNext (this=0x8b16370) at /home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp:166
#16 0xb658133f in KIMAP::Session::qt_static_metacall (_o=0x8b1a968, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0x8c634a8) at /home/lacsilva/Development/kdepim.d/kdepimlibs/BUILD/kimap/moc_session.cpp:88
#17 0xb73609aa in QMetaCallEvent::placeMetaCall (this=0x8af5ee8, object=0x8b1a968) at kernel/qobject.cpp:525
#18 0xb7364eeb in QObject::event (this=0x8b1a968, e=0x8af5ee8) at kernel/qobject.cpp:1195
#19 0xb683f39c in QApplicationPrivate::notify_helper (this=0x89dac10, receiver=0x8b1a968, e=0x8af5ee8) at kernel/qapplication.cpp:4562
#20 0xb6843daf in QApplication::notify (this=0x8af5ee8, receiver=0x8b1a968, e=0x8af5ee8) at kernel/qapplication.cpp:3944
#21 0xb5df5e91 in KApplication::notify (this=0xbf9a04e4, receiver=0x8b1a968, event=0x8af5ee8) at ../../kdeui/kernel/kapplication.cpp:311
#22 0xb734e78e in QCoreApplication::notifyInternal (this=0xbf9a04e4, receiver=0x8b1a968, event=0x8af5ee8) at kernel/qcoreapplication.cpp:915
#23 0xb735297d in sendEvent (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#24 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x89b6af0) at kernel/qcoreapplication.cpp:1539
#25 0xb7352c0c in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1432
#26 0xb7380804 in sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#27 postEventSourceDispatch (s=0x89d3078) at kernel/qeventdispatcher_glib.cpp:279
#28 0xb54b09e3 in g_main_context_dispatch () from /lib/i386-linux-gnu/libglib-2.0.so.0
#29 0xb54b0d80 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#30 0xb54b0e61 in g_main_context_iteration () from /lib/i386-linux-gnu/libglib-2.0.so.0
#31 0xb7380981 in QEventDispatcherGlib::processEvents (this=0x89b7850, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#32 0xb68f59aa in QGuiEventDispatcherGlib::processEvents (this=0x89b7850, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#33 0xb734d26c in QEventLoop::processEvents (this=this@entry=0xbf9a0448, flags=...) at kernel/qeventloop.cpp:149
#34 0xb734d561 in QEventLoop::exec (this=0xbf9a0448, flags=...) at kernel/qeventloop.cpp:204
#35 0xb7352cba in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187
#36 0xb683cfc4 in QApplication::exec () at kernel/qapplication.cpp:3823
#37 0xb7667f53 in Akonadi::ResourceBase::init (r=0x8afc060) at /home/lacsilva/Development/kdepim.d/kdepimlibs/akonadi/resourcebase.cpp:451
#38 0x08060eb0 in Akonadi::ResourceBase::init<ImapResource> (argc=argc@entry=3, argv=argv@entry=0xbf9a05c4) at /usr/include/akonadi/resourcebase.h:188
#39 0x0805973b in main (argc=3, argv=0xbf9a05c4) at /home/lacsilva/Development/kdepim.d/kdepim-runtime/resources/imap/imapresource.cpp:676

Possible duplicates by query: bug 307621, bug 302243, bug 298008, bug 298006, bug 298005.

Reported using DrKonqi
Comment 1 bosyber 2012-12-14 08:45:39 UTC
Created attachment 75822 [details]
New crash information added by DrKonqi

akonadi_imap_resource (4.9) on KDE Platform 4.9.90 using Qt 4.8.5

- What I was doing when the application crashed:

starting project-neon kontact - imap resource for one of my accounts crashed.

-- Backtrace (Reduced):
#6  0x00007f2840193425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#7  0x00007f2840196b8b in __GI_abort () at abort.c:91
[...]
#11 0x00007f284413d7bc in qt_assert (assertion=0x7f2842b5dc9d "!socketTimer.isActive()", file=0x7f2842b5dbb8 "/build/buildd/project-neon-kdepimlibs-2+git20121212+r12790/kimap/session.cpp", line=462) at global/qglobal.cpp:2018
#12 0x00007f2842b4203f in KIMAP::SessionPrivate::startSocketTimer (this=0x1002bc0) at /build/buildd/project-neon-kdepimlibs-2+git20121212+r12790/kimap/session.cpp:462
#13 0x00007f2842b40a17 in KIMAP::SessionPrivate::doStartNext (this=0x1002bc0) at /build/buildd/project-neon-kdepimlibs-2+git20121212+r12790/kimap/session.cpp:166
Comment 2 Jekyll Wu 2012-12-19 16:30:14 UTC
*** Bug 311938 has been marked as a duplicate of this bug. ***
Comment 3 Luis Silva 2013-01-02 18:34:54 UTC
Created attachment 76147 [details]
New crash information added by DrKonqi

akonadi_imap_resource (4.10) on KDE Platform 4.9.95 using Qt 4.8.3

- What I was doing when the application crashed:

there was a mail check running in the background.

-- Backtrace (Reduced):
#8  0xb564192f in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:63
#9  0xb5644ec3 in __GI_abort () at abort.c:90
[...]
#13 0xb71b5ce5 in qt_assert (assertion=0xb651e73d "!socketTimer.isActive()", file=0xb6521238 "/home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp", line=462) at global/qglobal.cpp:2016
#14 0xb6503a05 in KIMAP::SessionPrivate::startSocketTimer (this=this@entry=0x9b564e0) at /home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp:462
#15 0xb65054c1 in KIMAP::SessionPrivate::doStartNext (this=0x9b564e0) at /home/lacsilva/Development/kdepim.d/kdepimlibs/kimap/session.cpp:166
Comment 4 Daniel Vrátil 2013-02-27 14:56:39 UTC
I'm able to reproduce this with our corporate Zimbra server and I guess I found the problem :-)

KIMAP session does not handle "BYE" command when the server disconnects us, because this appears in console:

A message was received from the server with no job to handle it: "* BYE X.Y.Z.redhat.com Zimbra IMAP4rev1 server closing connection " "(2a20425945207a6d61696c31342e636f6c6c61622e70726f642e696e742e706878322e7265646861742e636f6d205a696d62726120494d415034726576312073657276657220636c6f73696e6720636f6e6e656374696f6e20)" 

When email check is triggered after this, the  Q_ASSERT( !socketTimer.isActive() ) occurs
Comment 5 Christian Mollekopf 2013-07-11 07:59:07 UTC
Created attachment 81054 [details]
New crash information added by DrKonqi

akonadi_imap_resource (4.10) on KDE Platform 4.10.4 using Qt 4.8.4

- What I was doing when the application crashed:
resumed from sleep.

Current 4.10 branch compiled from sources (4.10.5 bd7f89d403d77a5cbd14c5ba7e6021c380212ccb)

From the console:
akonadi_imap_resource_7(20686)/kdepimlibs (kimap) ImapIdleManager::onIdleStopped: IDLE dropped maybe we should reconnect?
akonadi_imap_resource_7(20686) ImapIdleManager::reconnect: attempting to reconnect IDLE session
ASSERT: "!socketTimer.isActive()" in file /home/chrigi/devel/kde/kdepimlibs/kimap/session.cpp, line 463
KCrash: Application 'akonadi_imap_resource' crashing...
KCrash: Attempting to start /usr/libexec/kde4/drkonqi from kdeinit
sock_file=/home/devel/.kde4src/socket-localhost.localdomain/kdeinit4__0
Lost connection to resource "org.freedesktop.Akonadi.Resource.akonadi_imap_resource_7" , discarding cached interface 
kwalletd(5507)/kdeui (Wallet) KWalletD::slotServiceOwnerChanged: slotServiceOwnerChanged  ":1.257" ,  ":1.257" ,  ""
void Akonadi::NotificationSource::serviceUnregistered(const QString&) Notification source "akonadi_imap_resource_7" now serving: () 
void Akonadi::NotificationSource::unsubscribe() "akonadi_imap_resource_7" 
akonadi_imap_resource_9(20929)/kdepimlibs (kimap) ImapIdleManager::onIdleStopped: IDLE dropped maybe we should reconnect?
akonadi_imap_resource_9(20929) ImapIdleManager::reconnect: attempting to reconnect IDLE session
ASSERT: "!socketTimer.isActive()" in file /home/chrigi/devel/kde/kdepimlibs/kimap/session.cpp, line 463
KCrash: Application 'akonadi_imap_resource' crashing...
KCrash: Attempting to start /usr/libexec/kde4/drkonqi from kdeinit
sock_file=/home/devel/.kde4src/socket-localhost.localdomain/kdeinit4__0
Lost connection to resource "org.freedesktop.Akonadi.Resource.akonadi_imap_resource_9" , discarding cached interface

-- Backtrace (Reduced):
#6  0x0000003a51e35ba5 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:63
#7  0x0000003a51e37358 in __GI_abort () at abort.c:90
[...]
#11 0x00007ff6be75cca9 in KIMAP::SessionPrivate::startSocketTimer (this=0xfc7e10) at /home/chrigi/devel/kde/kdepimlibs/kimap/session.cpp:463
#12 0x00007ff6be75b60f in KIMAP::SessionPrivate::doStartNext (this=0xfc7e10) at /home/chrigi/devel/kde/kdepimlibs/kimap/session.cpp:166
#13 0x00007ff6be75cfdd in KIMAP::Session::qt_static_metacall (_o=0xfc6240, _c=QMetaObject::InvokeMetaMethod, _id=4, _a=0xfcea40) at /home/chrigi/devel/kde/build/kolab410/kdepimlibs/kimap/moc_session.cpp:87
Comment 6 Christian Mollekopf 2013-07-11 08:04:39 UTC
(In reply to comment #5)

Missed parts of the output, here are the remaining lines.

> From the console:
A message was received from the server with no job to handle it: "* BYE idle for too long " "(2a204259452069646c6520666f7220746f6f206c6f6e6720)" 
A message was received from the server with no job to handle it: "* BYE idle for too long " "(2a204259452069646c6520666f7220746f6f206c6f6e6720)" 
A message was received from the server with no job to handle it: "* BYE idle for too long " "(2a204259452069646c6520666f7220746f6f206c6f6e6720)" 
> akonadi_imap_resource_7(20686)/kdepimlibs (kimap)
> ImapIdleManager::onIdleStopped: IDLE dropped maybe we should reconnect?
> akonadi_imap_resource_7(20686) ImapIdleManager::reconnect: attempting to
> reconnect IDLE session
> ASSERT: "!socketTimer.isActive()" in file
> /home/chrigi/devel/kde/kdepimlibs/kimap/session.cpp, line 463
> KCrash: Application 'akonadi_imap_resource' crashing...
> KCrash: Attempting to start /usr/libexec/kde4/drkonqi from kdeinit
> sock_file=/home/devel/.kde4src/socket-localhost.localdomain/kdeinit4__0
> Lost connection to resource
> "org.freedesktop.Akonadi.Resource.akonadi_imap_resource_7" , discarding
> cached interface 
> kwalletd(5507)/kdeui (Wallet) KWalletD::slotServiceOwnerChanged:
> slotServiceOwnerChanged  ":1.257" ,  ":1.257" ,  ""
> void Akonadi::NotificationSource::serviceUnregistered(const QString&)
> Notification source "akonadi_imap_resource_7" now serving: () 
> void Akonadi::NotificationSource::unsubscribe() "akonadi_imap_resource_7" 
> akonadi_imap_resource_9(20929)/kdepimlibs (kimap)
> ImapIdleManager::onIdleStopped: IDLE dropped maybe we should reconnect?
> akonadi_imap_resource_9(20929) ImapIdleManager::reconnect: attempting to
> reconnect IDLE session
> ASSERT: "!socketTimer.isActive()" in file
> /home/chrigi/devel/kde/kdepimlibs/kimap/session.cpp, line 463
> KCrash: Application 'akonadi_imap_resource' crashing...
> KCrash: Attempting to start /usr/libexec/kde4/drkonqi from kdeinit
> sock_file=/home/devel/.kde4src/socket-localhost.localdomain/kdeinit4__0
> Lost connection to resource
> "org.freedesktop.Akonadi.Resource.akonadi_imap_resource_9" , discarding
> cached interface

Looks indeed like BYE is not handled appropriately.
Comment 7 Kevin Ottens 2013-11-16 07:28:14 UTC
The IMAP resource has a new maintainer, reassigning to him.
Comment 8 Christian Mollekopf 2013-12-09 21:38:34 UTC
*** Bug 324432 has been marked as a duplicate of this bug. ***
Comment 9 Christian Mollekopf 2013-12-10 10:33:19 UTC
Git commit d0cd431fbc433f9bdcd464340027140a737647ca by Christian Mollekopf.
Committed on 10/12/2013 at 09:09.
Pushed by cmollekopf into branch 'master'.

Made the socketTimer a bit simpler and more robust.

There is no need for the code to not be a little more forgiving, and we can easily get into a situation
with the timer already running on startNext. e.g. due to socketActivity of due to unhandled data (BYE).

This will hopefully fix the ASSERT people were running into.

M  +6    -14   kimap/session.cpp

http://commits.kde.org/kdepimlibs/d0cd431fbc433f9bdcd464340027140a737647ca
Comment 10 Christian Mollekopf 2013-12-10 10:33:20 UTC
Git commit 05738951d9b1a78b9832be5eda3c1b0fe99f12bd by Christian Mollekopf.
Committed on 10/12/2013 at 10:22.
Pushed by cmollekopf into branch 'master'.

Handle BYE.

M  +12   -0    kimap/session.cpp

http://commits.kde.org/kdepimlibs/05738951d9b1a78b9832be5eda3c1b0fe99f12bd