Bug 397515 - crash (reentrancy, null mutex) in akonadiserver when moving an email
Summary: crash (reentrancy, null mutex) in akonadiserver when moving an email
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: 5.8.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Daniel Vrátil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-16 11:29 UTC by David Faure
Modified: 2018-08-25 11:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Faure 2018-08-16 11:29:17 UTC
Application: akonadiserver (5.8.2)

Qt Version: 5.11.1
Frameworks Version: 5.47.0
Operating System: Linux 4.4.138-59-default x86_64
Distribution: "openSUSE Leap 42.3"

-- Information about the crash:
Hi Dan :)
Sabine got this crash twice in a row today, with 18.04.2 opensuse packages.
Triggered simply by moving a mail from the imap inbox to another imap folder. I know you rewrote the notification stuff, but is this use of QEventLoop::exec still there in NotificationManager::waitForSocketData()? Note how it leads to unexpected reentrancy, NotificationManager::emitPendingNotifications() being called via a timer, and I think this could be the reason for the crash?

-- Backtrace:
Application: Akonadi Server (akonadiserver), signal: Segmentation fault

Thread 3 (Thread 0x7f21e203f700 (LWP 5433)):
[KCrash Handler]
#6  std::__atomic_base<QMutexData*>::compare_exchange_strong (__m2=std::memory_order_acquire, __m1=std::memory_order_acquire, __p2=0x1, __p1=@0x7f21e203e0e0: 0x0, this=0x10) at /usr/include/c++/4.8/bits/atomic_base.h:844
#7  std::atomic<QMutexData*>::compare_exchange_strong (__m2=std::memory_order_acquire, __m1=std::memory_order_acquire, __p2=0x1, __p1=@0x7f21e203e0e0: 0x0, this=0x10) at /usr/include/c++/4.8/atomic:432
#8  QAtomicOps<QMutexData*>::testAndSetAcquire<QMutexData*> (currentValue=<synthetic pointer>, newValue=0x1, expectedValue=0x0, _q_value=...) at ../../src/corelib/thread/qatomic_cxx11.h:290
#9  QBasicAtomicPointer<QMutexData>::testAndSetAcquire (currentValue=<synthetic pointer>: <optimized out>, newValue=0x1, expectedValue=0x0, this=0x10) at ../../src/corelib/thread/qbasicatomic.h:263
#10 QBasicMutex::fastTryLock (current=<synthetic pointer>: <optimized out>, this=0x10) at thread/qmutex.h:107
#11 QMutex::lock (this=0x10) at thread/qmutex.cpp:224
#12 0x00000000004fd149 in Akonadi::Server::NotificationSubscriber::notify(QSharedPointer<Akonadi::Protocol::ChangeNotification> const&) ()
#13 0x00000000004f82ab in Akonadi::Server::NotificationManager::emitPendingNotifications() ()
#14 0x00007f21ecd2ec13 in QtPrivate::QSlotObjectBase::call (a=0x7f21e203e3a0, r=0xc6fd90, this=0x7f21d4003220) at ../../src/corelib/kernel/qobjectdefs_impl.h:376
#15 QMetaObject::activate (sender=sender@entry=0x7f21d40013d0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7f21e203e3a0) at kernel/qobject.cpp:3754
#16 0x00007f21ecd2f227 in QMetaObject::activate (sender=sender@entry=0x7f21d40013d0, m=m@entry=0x7f21ed180420 <QTimer::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7f21e203e3a0) at kernel/qobject.cpp:3633
#17 0x00007f21ecd3bf57 in QTimer::timeout (this=this@entry=0x7f21d40013d0, _t1=_t1@entry=...) at .moc/moc_qtimer.cpp:200
#18 0x00007f21ecd3c232 in QTimer::timerEvent (this=0x7f21d40013d0, e=<optimized out>) at kernel/qtimer.cpp:255
#19 0x00007f21ecd2fd44 in QObject::event (this=0x7f21d40013d0, e=<optimized out>) at kernel/qobject.cpp:1232
#20 0x00007f21ecd048f5 in QCoreApplication::notifyInternal2 (receiver=0x7f21d40013d0, event=event@entry=0x7f21e203e580) at kernel/qcoreapplication.cpp:1048
#21 0x00007f21ecd5688e in QCoreApplication::sendEvent (event=0x7f21e203e580, receiver=<optimized out>) at ../../src/corelib/kernel/qcoreapplication.h:234
#22 QTimerInfoList::activateTimers (this=0x7f21d4002ed0) at kernel/qtimerinfo_unix.cpp:643
#23 0x00007f21ecd56ed1 in timerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:182
#24 0x00007f21e8c6d134 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#25 0x00007f21e8c6d388 in ?? () from /usr/lib64/libglib-2.0.so.0
#26 0x00007f21e8c6d42c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#27 0x00007f21ecd5721b in QEventDispatcherGlib::processEvents (this=0x7f21d40008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#28 0x00007f21ecd0308b in QEventLoop::exec (this=0x7f21e203e810, flags=...) at kernel/qeventloop.cpp:214
#29 0x00000000004f8cba in Akonadi::Server::NotificationManager::waitForSocketData() ()
#30 0x00007f21ecd3bfc6 in QtPrivate::QSlotObjectBase::call (a=0x7f21e203e8b0, r=<optimized out>, this=<optimized out>) at ../../src/corelib/kernel/qobjectdefs_impl.h:376
#31 QSingleShotTimer::timerEvent (this=0x7f21d4010850) at kernel/qtimer.cpp:318
#32 0x00007f21ecd2fd44 in QObject::event (this=0x7f21d4010850, e=<optimized out>) at kernel/qobject.cpp:1232
#33 0x00007f21ecd048f5 in QCoreApplication::notifyInternal2 (receiver=0x7f21d4010850, event=event@entry=0x7f21e203ea70) at kernel/qcoreapplication.cpp:1048
#34 0x00007f21ecd5688e in QCoreApplication::sendEvent (event=0x7f21e203ea70, receiver=<optimized out>) at ../../src/corelib/kernel/qcoreapplication.h:234
#35 QTimerInfoList::activateTimers (this=0x7f21d4002ed0) at kernel/qtimerinfo_unix.cpp:643
#36 0x00007f21ecd56ed1 in timerSourceDispatch (source=<optimized out>) at kernel/qeventdispatcher_glib.cpp:182
#37 0x00007f21e8c6d134 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#38 0x00007f21e8c6d388 in ?? () from /usr/lib64/libglib-2.0.so.0
#39 0x00007f21e8c6d42c in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#40 0x00007f21ecd571fc in QEventDispatcherGlib::processEvents (this=0x7f21d40008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#41 0x00007f21ecd0308b in QEventLoop::exec (this=this@entry=0x7f21e203ecb0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:214
#42 0x00007f21ecb5298a in QThread::exec (this=<optimized out>) at thread/qthread.cpp:525
#43 0x00007f21ecb5d3df in QThreadPrivate::start (arg=0xc8c2d0) at thread/qthread_unix.cpp:367
#44 0x00007f21eb012724 in start_thread () from /lib64/libpthread.so.0
#45 0x00007f21ec24ae8d in clone () from /lib64/libc.so.6

[other threads omitted, nothing interesting there]
Comment 1 David Faure 2018-08-16 11:31:17 UTC
Hmm I think that the crash only happens after I enable Notification Monitor in akonadiconsole.

The root bug is a failure to move an email, the use of akonadiconsole was merely to debug that...
Comment 2 Daniel Vrátil 2018-08-25 11:33:47 UTC
This should be solved on 5.9 (18.08), the weird code with nested event loop is gone and the whole thing is a bit more sensible now.