Bug 260009

Summary: akonadi_resource crash on resume from suspend to RAM
Product: [Frameworks and Libraries] Akonadi Reporter: Andreas Karrenbauer <andreas.karrenbauer>
Component: IMAP resourceAssignee: Kevin Ottens <ervin>
Status: RESOLVED FIXED    
Severity: crash CC: alex.merry, kdepim-bugs, vkrause
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: OpenSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Andreas Karrenbauer 2010-12-15 23:14:15 UTC
Application: akonadi_imap_resource (0.1)
KDE Platform Version: 4.5.85 (4.6 Beta2)
Qt Version: 4.7.1
Operating System: Linux 2.6.34.7-0.5-default x86_64
Distribution: "openSUSE 11.3 (x86_64)"

-- Information about the crash:
- What I was doing when the application crashed:
system has been resumed from suspend from RAM. Crash seemed to happen shortly after the network was up again.

-- Backtrace:
Application: Akonadi Resource (akonadi_imap_resource), signal: Segmentation fault
[Current thread is 1 (Thread 0x7fcd1fc7c760 (LWP 3173))]

Thread 5 (Thread 0x7fcd0aa1f710 (LWP 12941)):
#0  0x00007fcd1b0bb6a0 in __pthread_mutex_unlock_usercnt () from /lib64/libpthread.so.0
#1  0x00007fcd1a15f712 in g_main_context_check () from /usr/lib64/libglib-2.0.so.0
#2  0x00007fcd1a15fff2 in ?? () from /usr/lib64/libglib-2.0.so.0
#3  0x00007fcd1a160510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#4  0x00007fcd1f127ae6 in QEventDispatcherGlib::processEvents (this=0x778cd0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:424
#5  0x00007fcd1f0fc262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#6  0x00007fcd1f0fc475 in QEventLoop::exec (this=0x7fcd0aa1ee00, flags=...) at kernel/qeventloop.cpp:201
#7  0x00007fcd1f00f1a4 in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#8  0x00007fcd1dd8dc43 in KIMAP::SessionThread::run (this=0x8a7930) at /usr/src/debug/kdepimlibs-4.5.85/kimap/sessionthread.cpp:166
#9  0x00007fcd1f011a1e in QThreadPrivate::start (arg=0x8a7930) at thread/qthread_unix.cpp:285
#10 0x00007fcd1b0b7a4f in start_thread () from /lib64/libpthread.so.0
#11 0x00007fcd1b7f982d in clone () from /lib64/libc.so.6
#12 0x0000000000000000 in ?? ()

Thread 4 (Thread 0x7fcd0d2d6710 (LWP 15281)):
#0  0x00007fcd1a137f20 in g_ptr_array_set_size () from /usr/lib64/libglib-2.0.so.0
#1  0x00007fcd1a15ee88 in g_main_context_prepare () from /usr/lib64/libglib-2.0.so.0
#2  0x00007fcd1a15fe69 in ?? () from /usr/lib64/libglib-2.0.so.0
#3  0x00007fcd1a160510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#4  0x00007fcd1f127ae6 in QEventDispatcherGlib::processEvents (this=0x7d8b20, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:424
#5  0x00007fcd1f0fc262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#6  0x00007fcd1f0fc475 in QEventLoop::exec (this=0x7fcd0d2d5e00, flags=...) at kernel/qeventloop.cpp:201
#7  0x00007fcd1f00f1a4 in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#8  0x00007fcd1dd8dc43 in KIMAP::SessionThread::run (this=0x8a7db0) at /usr/src/debug/kdepimlibs-4.5.85/kimap/sessionthread.cpp:166
#9  0x00007fcd1f011a1e in QThreadPrivate::start (arg=0x8a7db0) at thread/qthread_unix.cpp:285
#10 0x00007fcd1b0b7a4f in start_thread () from /lib64/libpthread.so.0
#11 0x00007fcd1b7f982d in clone () from /lib64/libc.so.6
#12 0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7fcd0dad7710 (LWP 15799)):
#0  0x00007fcd1b7f06b3 in poll () from /lib64/libc.so.6
#1  0x00007fcd1a15ffd4 in ?? () from /usr/lib64/libglib-2.0.so.0
#2  0x00007fcd1a160510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#3  0x00007fcd1f127ae6 in QEventDispatcherGlib::processEvents (this=0x89c0b0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:424
#4  0x00007fcd1f0fc262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#5  0x00007fcd1f0fc475 in QEventLoop::exec (this=0x7fcd0dad6e00, flags=...) at kernel/qeventloop.cpp:201
#6  0x00007fcd1f00f1a4 in QThread::exec (this=<value optimized out>) at thread/qthread.cpp:490
#7  0x00007fcd1dd8dc43 in KIMAP::SessionThread::run (this=0x9b1ee0) at /usr/src/debug/kdepimlibs-4.5.85/kimap/sessionthread.cpp:166
#8  0x00007fcd1f011a1e in QThreadPrivate::start (arg=0x9b1ee0) at thread/qthread_unix.cpp:285
#9  0x00007fcd1b0b7a4f in start_thread () from /lib64/libpthread.so.0
#10 0x00007fcd1b7f982d in clone () from /lib64/libc.so.6
#11 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7fcd0a00f710 (LWP 15804)):
#0  0x00007fcd1b0bc709 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007fcd1f012072 in wait (this=<value optimized out>, mutex=0x7df970, time=30000) at thread/qwaitcondition_unix.cpp:86
#2  QWaitCondition::wait (this=<value optimized out>, mutex=0x7df970, time=30000) at thread/qwaitcondition_unix.cpp:160
#3  0x00007fcd1f007e98 in QThreadPoolThread::run (this=0x7df530) at concurrent/qthreadpool.cpp:140
#4  0x00007fcd1f011a1e in QThreadPrivate::start (arg=0x7df530) at thread/qthread_unix.cpp:285
#5  0x00007fcd1b0b7a4f in start_thread () from /lib64/libpthread.so.0
#6  0x00007fcd1b7f982d in clone () from /lib64/libc.so.6
#7  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7fcd1fc7c760 (LWP 3173)):
[KCrash Handler]
#6  QString (this=0x0) at /usr/include/QtCore/qstring.h:728
#7  ImapAccount::server (this=0x0) at /usr/src/debug/kdepim-runtime-4.5.85/resources/imap/imapaccount.cpp:48
#8  0x00000000004571e1 in SessionPool::cancelSessionCreation (this=0x797c90, session=0x7d89e0, errorCode=4, errorMessage=...)
    at /usr/src/debug/kdepim-runtime-4.5.85/resources/imap/sessionpool.cpp:228
#9  0x000000000045747b in SessionPool::onEarlyConnectionLost (this=0x797c90) at /usr/src/debug/kdepim-runtime-4.5.85/resources/imap/sessionpool.cpp:351
#10 0x0000000000458de8 in SessionPool::qt_metacall (this=0x797c90, _c=QMetaObject::InvokeMetaMethod, _id=14, _a=0x7fff04ccbf90)
    at /usr/src/debug/kdepim-runtime-4.5.85/build/resources/imap/sessionpool.moc:122
#11 0x00007fcd1f111fef in QMetaObject::activate (sender=0x7d89e0, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3272
#12 0x00007fcd1dd93629 in KIMAP::SessionPrivate::socketDisconnected (this=0x88c330) at /usr/src/debug/kdepimlibs-4.5.85/kimap/session.cpp:336
#13 0x00007fcd1ddaa74d in KIMAP::Session::qt_metacall (this=0x7d89e0, _c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0xc18350)
    at /usr/src/debug/kdepimlibs-4.5.85/build/kimap/session.moc:109
#14 0x00007fcd1f110c6a in QObject::event (this=0x7d89e0, e=<value optimized out>) at kernel/qobject.cpp:1211
#15 0x00007fcd1e4bacd4 in QApplicationPrivate::notify_helper (this=0x6a7d30, receiver=0x7d89e0, e=0x877b20) at kernel/qapplication.cpp:4445
#16 0x00007fcd1e4c31ca in QApplication::notify (this=<value optimized out>, receiver=0x7d89e0, e=0x877b20) at kernel/qapplication.cpp:4324
#17 0x00007fcd1c5e7c66 in KApplication::notify (this=0x7fff04ccca20, receiver=0x7d89e0, event=0x877b20) at /usr/src/debug/kdelibs-4.5.85/kdeui/kernel/kapplication.cpp:311
#18 0x00007fcd1f0fce2c in QCoreApplication::notifyInternal (this=0x7fff04ccca20, receiver=0x7d89e0, event=0x877b20) at kernel/qcoreapplication.cpp:732
#19 0x00007fcd1f100625 in sendEvent (receiver=0x0, event_type=0, data=0x688350) at kernel/qcoreapplication.h:215
#20 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x688350) at kernel/qcoreapplication.cpp:1373
#21 0x00007fcd1f1278f3 in sendPostedEvents (s=0x6ab910) at kernel/qcoreapplication.h:220
#22 postEventSourceDispatch (s=0x6ab910) at kernel/qeventdispatcher_glib.cpp:277
#23 0x00007fcd1a15fa93 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#24 0x00007fcd1a160270 in ?? () from /usr/lib64/libglib-2.0.so.0
#25 0x00007fcd1a160510 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#26 0x00007fcd1f127a8f in QEventDispatcherGlib::processEvents (this=0x68e050, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:422
#27 0x00007fcd1e55feae in QGuiEventDispatcherGlib::processEvents (this=<value optimized out>, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:204
#28 0x00007fcd1f0fc262 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#29 0x00007fcd1f0fc475 in QEventLoop::exec (this=0x7fff04ccc9a0, flags=...) at kernel/qeventloop.cpp:201
#30 0x00007fcd1f1008db in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1009
#31 0x00007fcd1f736712 in Akonadi::ResourceBase::init (r=0x737760) at /usr/src/debug/kdepimlibs-4.5.85/akonadi/resourcebase.cpp:283
#32 0x0000000000420008 in init<ImapResource> (argc=<value optimized out>, argv=<value optimized out>) at /usr/include/akonadi/resourcebase.h:188
#33 main (argc=<value optimized out>, argv=<value optimized out>) at /usr/src/debug/kdepim-runtime-4.5.85/resources/imap/imapresource.cpp:580

Reported using DrKonqi
Comment 1 Volker Krause 2010-12-30 14:06:43 UTC
*** Bug 260931 has been marked as a duplicate of this bug. ***
Comment 2 Volker Krause 2011-01-12 16:04:16 UTC
commit c6c086a80162d796f3cb2a692f516e092d4faa2c
branch master
Author: Volker Krause <vkrause@kde.org>
Date:   Wed Jan 12 16:02:46 2011 +0100

    Fix crash when losing network while trying to connect a new session.
    
    In this case all already ready sessions disconnect, and with none left, the
    account object is deleted to prepare the full reconnect. The pending
    session then fails as well, at which point accessing m_account will crash.
    
    BUG: 260009

diff --git a/resources/imap/sessionpool.cpp b/resources/imap/sessionpool.cpp
index f541459..e312c1c 100644
--- a/resources/imap/sessionpool.cpp
+++ b/resources/imap/sessionpool.cpp
@@ -216,10 +216,10 @@ void SessionPool::cancelSessionCreation( KIMAP::Session *session, int errorCode,
   m_pendingInitialSession = 0;
 
   if ( !m_initialConnectDone ) {
-    emit connectDone( errorCode,
-                      i18n( "Could not connect to the IMAP-server %1.\n%2",
-                            m_account->server(),
-                            errorMessage ) );
+    if ( m_account )
+      emit connectDone( errorCode, i18n( "Could not connect to the IMAP-server %1.\n%2", m_account->server(), errorMessage ) );
+    else // this case can happen when we loose all ready connections while trying to establish a new one for example
+      emit connectDone( errorCode, i18n( "Cound not connect to the IMAP server.\n%1", errorMessage ) );
     disconnect();
     killSession( session, LogoutSession );
   } else {