[Kde-pim] imap resource deadlocks on socket error

David Faure faure at kde.org
Fri Nov 16 18:25:08 GMT 2012


The "automatic fallback for SSL/TLS protocol versions" commit (d8eeb4cb0c0c7 in kdepimlibs) leads to the following deadlock due to a non-recursive mutex being locked recursively (in a single thread).

(gdb) bt
#0  0x00007f109fb87cd9 in syscall () from /lib64/libc.so.6
#1  0x00007f10a44cb6b2 in _q_futex (addr=0xa00880, op=0, val=2, timeout=0x0, addr2=0x0, val2=0) at thread/qmutex_unix.cpp:99
#2  0x00007f10a44cb76a in QMutexPrivate::wait (this=0xa00880, timeout=-1) at thread/qmutex_unix.cpp:113
#3  0x00007f10a44c6353 in QMutex::lockInternal (this=0x9f1810) at thread/qmutex.cpp:450
#4  0x00007f10a44c5f3e in QMutex::lock (this=0x9f1810) at thread/qmutex.cpp:177
#5  0x00007f10a2bdf904 in QMutex::lockInline (this=0x9f1810) at /d/qt/4/qt-for-trunk/include/QtCore/../../src/corelib/thread/qmutex.h:198
#6  0x00007f10a2bdf83b in QMutexLocker::QMutexLocker (this=0x7f1091112520, m=0x9f1810) at /d/qt/4/qt-for-trunk/include/QtCore/../../src/corelib/thread/qmutex.h:109
#7  0x00007f10a2bde40e in KIMAP::SessionThread::reconnect (this=0x9f17d0) at /d/kde/src/4/kdepimlibs/kimap/sessionthread.cpp:144
      144├>  QMutexLocker locker(&m_mutex);
#8  0x00007f10a2bdea80 in KIMAP::SessionThread::socketDisconnected (this=0x9f17d0) at /d/kde/src/4/kdepimlibs/kimap/sessionthread.cpp:219
[...]


#32 0x00007f10a07b35d6 in KTcpSocket::disconnectFromHost (this=0x7f108c144bc0) at /d/kde/src/4/kdelibs/kdecore/network/ktcpsocket.cpp:543
#33 0x00007f10a2bdec84 in KIMAP::SessionThread::socketError (this=0x9f17d0) at /d/kde/src/4/kdepimlibs/kimap/sessionthread.cpp:230
225│ void SessionThread::socketError()
226│ {  
227│   QMutexLocker locker( &m_mutex );
228│
229│   if ( doSslFallback ) {
230├>    m_socket->disconnectFromHost();
231│   } else {
232│     QMetaObject::invokeMethod( m_session, "socketError" );
233│   }
234│ }

#34 0x00007f10a2bdf55d in KIMAP::SessionThread::qt_static_metacall (_o=0x9f17d0, _c=QMetaObject::InvokeMetaMethod, _id=11, _a=0x7f1091113e90) at /d/kde/build/4/kdepimlibs/kimap/sessionthread_p.moc:84
#35 0x00007f10a461ef1e in QMetaObject::activate (sender=0x7f108c144bc0, m=0x7f10a0b0c580, local_signal_index=3, argv=0x7f1091113e90) at kernel/qobject.cpp:3540
#36 0x00007f10a07b58e6 in KTcpSocket::error (this=0x7f108c144bc0, _t1=KTcpSocket::RemoteHostClosedError) at /d/kde/build/4/kdelibs/kdecore/ktcpsocket.moc:164


In other words, the disconnectFromHost() leads to reconnect() in the same class,
and the mutex is already locked => deadlock.

Maybe this code should call locker.unlock() before disconnectFromHost()?
Unless the disconnectFromHost() wasn't meant to end up calling reconnect()?

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list