Bug 450217

Summary: (SEGV) Crash in Akonadi::Server::AkonadiServer::connectionDisconnected
Product: [Frameworks and Libraries] Akonadi Reporter: postix <postix>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: abode091, avemilia, bughunt, bugs.kde.org, bugs.kde.org, cma63, eric1, holger.werb, jwd, kde, krutalevex, kurobeats, MacrosV, madLyfe, mrnycticorax, oldkid, ondrej.mach, peterthecoder, philipp.reichmuth, postix, razvan.ciochina, sknauss, tian.tian098, veehexx
Priority: VHI Keywords: wayland
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 23.04.1
Attachments: bt full

Description postix 2022-02-14 13:55:35 UTC
SUMMARY

```
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007fe2969f62d3 in __pthread_kill_internal (signo=11, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007fe2969a6356 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#3  0x00007fe297792d36 in KCrash::defaultCrashHandler (sig=11) at /usr/src/debug/kcrash-5.90.0-1.1.x86_64/src/kcrash.cpp:624
#4  <signal handler called>
#5  std::default_delete<Akonadi::Server::Connection>::operator() (__ptr=0x111, this=<optimized out>) at /usr/include/c++/11/bits/unique_ptr.h:79
#6  std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> >::~unique_ptr (this=<optimized out>, this=<optimized out>) at /usr/include/c++/11/bits/unique_ptr.h:361
#7  __gnu_cxx::new_allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > >::destroy<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > (__p=<optimized out>, this=<optimized out>) at /usr/include/c++/11/ext/new_allocator.h:168
#8  std::allocator_traits<std::allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > >::destroy<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > (__p=<optimized out>, __a=...) at /usr/include/c++/11/bits/alloc_traits.h:535
#9  std::vector<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> >, std::allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > >::_M_erase (__position=std::unique_ptr<Akonadi::Server::Connection> = {get() = 0x559e2e5a0bc0}, this=<optimized out>) at /usr/include/c++/11/bits/vector.tcc:177
#10 std::vector<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> >, std::allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > >::erase (__position=std::unique_ptr<Akonadi::Server::Connection> = {get() = 0x559e2e5a0bc0}, this=<optimized out>) at /usr/include/c++/11/bits/stl_vector.h:1431
#11 Akonadi::Server::AkonadiServer::connectionDisconnected (this=<optimized out>) at /usr/src/debug/akonadi-server-21.12.2-1.1.x86_64/src/server/akonadi.cpp:234
#12 0x00007fe2970b949e in QObject::event (this=0x7ffc2a007220, e=0x559e2e599520) at kernel/qobject.cpp:1314
#13 0x00007fe29708cdff in doNotify (event=0x559e2e599520, receiver=0x7ffc2a007220) at kernel/qcoreapplication.cpp:1154
#14 QCoreApplication::notify (event=<optimized out>, receiver=<optimized out>, this=<optimized out>) at kernel/qcoreapplication.cpp:1140
#15 QCoreApplication::notifyInternal2 (receiver=0x7ffc2a007220, event=0x559e2e599520) at kernel/qcoreapplication.cpp:1064
#16 0x00007fe29708fe67 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x559e2e546e10) at kernel/qcoreapplication.cpp:1821
#17 0x00007fe2970e4ce3 in postEventSourceDispatch (s=s@entry=0x559e2e54ef50) at kernel/qeventdispatcher_glib.cpp:277
#18 0x00007fe2952c8d5f in g_main_dispatch (context=0x559e2e54ccc0) at ../glib/gmain.c:3381
#19 g_main_context_dispatch (context=0x559e2e54ccc0) at ../glib/gmain.c:4099
#20 0x00007fe2952c90e8 in g_main_context_iterate (context=context@entry=0x559e2e54ccc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4175
#21 0x00007fe2952c919f in g_main_context_iteration (context=0x559e2e54ccc0, may_block=1) at ../glib/gmain.c:4240
#22 0x00007fe2970e4364 in QEventDispatcherGlib::processEvents (this=0x559e2e54c3e0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#23 0x00007fe29708b82b in QEventLoop::exec (this=this@entry=0x7ffc2a007080, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#24 0x00007fe297093b00 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#25 0x0000559e2d25f6b6 in AkApplicationBase::exec (this=0x7ffc2a0071f0) at /usr/src/debug/akonadi-server-21.12.2-1.1.x86_64/src/shared/akapplication.cpp:107
#26 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/akonadi-server-21.12.2-1.1.x86_64/src/server/main.cpp:65
```

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220210
KDE Plasma Version: 5.24.0
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.5-1-default (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon RX 580 Series
Comment 1 postix 2022-04-07 08:55:35 UTC
Created attachment 148014 [details]
bt full

Right after KWin Wayland crashed due to #452044, Akonadi crashed too.

BACKTRACE

```
#4  <signal handler called>
#5  std::default_delete<Akonadi::Server::Connection>::operator() (__ptr=0x111, this=<optimized out>) at /usr/include/c++/11/bits/unique_ptr.h:79
#6  std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> >::~unique_ptr (this=<optimized out>, this=<optimized out>) at /usr/include/c++/11/bits/unique_ptr.h:361
#7  __gnu_cxx::new_allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > >::destroy<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > (__p=<optimized out>, this=<optimized out>) at /usr/include/c++/11/ext/new_allocator.h:168
#8  std::allocator_traits<std::allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > >::destroy<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > (__p=<optimized out>, __a=...) at /usr/include/c++/11/bits/alloc_traits.h:535
#9  std::vector<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> >, std::allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > >::_M_erase (__position=std::unique_ptr<Akonadi::Server::Connection> = {get() = 0x55766233e450}, this=<optimized out>) at /usr/include/c++/11/bits/vector.tcc:177
#10 std::vector<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> >, std::allocator<std::unique_ptr<Akonadi::Server::Connection, std::default_delete<Akonadi::Server::Connection> > > >::erase (__position=std::unique_ptr<Akonadi::Server::Connection> = {get() = 0x55766233e450}, this=<optimized out>) at /usr/include/c++/11/bits/stl_vector.h:1431
#11 Akonadi::Server::AkonadiServer::connectionDisconnected (this=<optimized out>) at /usr/src/debug/akonadi-server-21.12.3-2.2.x86_64/src/server/akonadi.cpp:234
#12 0x00007f185f1d84ae in QObject::event (this=0x7fffce646fe0, e=0x7f17fc005a00) at kernel/qobject.cpp:1314
#13 0x00007f185f1abe0f in doNotify (event=0x7f17fc005a00, receiver=0x7fffce646fe0) at kernel/qcoreapplication.cpp:1154
#14 QCoreApplication::notify (event=<optimized out>, receiver=<optimized out>, this=<optimized out>) at kernel/qcoreapplication.cpp:1140
#15 QCoreApplication::notifyInternal2 (receiver=0x7fffce646fe0, event=0x7f17fc005a00) at kernel/qcoreapplication.cpp:1064
#16 0x00007f185f1aee77 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x5576622eeb80) at kernel/qcoreapplication.cpp:1821
#17 0x00007f185f203d03 in postEventSourceDispatch (s=s@entry=0x55766232cca0) at kernel/qeventdispatcher_glib.cpp:277
#18 0x00007f185d3ca122 in g_main_dispatch (context=0x55766232aa10) at ../glib/gmain.c:3417
#19 g_main_context_dispatch (context=0x55766232aa10) at ../glib/gmain.c:4135
#20 0x00007f185d3ca4b8 in g_main_context_iterate (context=context@entry=0x55766232aa10, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4211
#21 0x00007f185d3ca56f in g_main_context_iteration (context=0x55766232aa10, may_block=1) at ../glib/gmain.c:4276
#22 0x00007f185f203384 in QEventDispatcherGlib::processEvents (this=0x55766232a130, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#23 0x00007f185f1aa83b in QEventLoop::exec (this=this@entry=0x7fffce646e40, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#24 0x00007f185f1b2b10 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#25 0x00005576607826b6 in AkApplicationBase::exec (this=0x7fffce646fb0) at /usr/src/debug/akonadi-server-21.12.3-2.2.x86_64/src/shared/akapplication.cpp:107
#26 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/akonadi-server-21.12.3-2.2.x86_64/src/server/main.cpp:65
```


SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220404
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.2
Kernel Version: 5.17.1-1-default (64-bit)
Graphics Platform: Wayland
Comment 2 postix 2022-04-07 09:00:53 UTC
*** Bug 442147 has been marked as a duplicate of this bug. ***
Comment 3 postix 2022-04-07 09:04:08 UTC
*** Bug 445249 has been marked as a duplicate of this bug. ***
Comment 4 postix 2022-04-07 09:05:14 UTC
*** Bug 447035 has been marked as a duplicate of this bug. ***
Comment 5 postix 2023-04-10 16:04:23 UTC
*** Bug 459186 has been marked as a duplicate of this bug. ***
Comment 6 postix 2023-04-10 16:04:52 UTC
*** Bug 462023 has been marked as a duplicate of this bug. ***
Comment 7 postix 2023-04-10 16:05:08 UTC
*** Bug 462597 has been marked as a duplicate of this bug. ***
Comment 8 postix 2023-04-10 16:05:49 UTC
*** Bug 462606 has been marked as a duplicate of this bug. ***
Comment 9 postix 2023-04-10 16:06:05 UTC
*** Bug 462670 has been marked as a duplicate of this bug. ***
Comment 10 postix 2023-04-10 16:06:19 UTC
*** Bug 462692 has been marked as a duplicate of this bug. ***
Comment 11 postix 2023-04-10 16:06:39 UTC
*** Bug 467430 has been marked as a duplicate of this bug. ***
Comment 12 postix 2023-04-10 16:06:54 UTC
*** Bug 467883 has been marked as a duplicate of this bug. ***
Comment 13 postix 2023-04-10 16:07:08 UTC
*** Bug 440175 has been marked as a duplicate of this bug. ***
Comment 14 postix 2023-04-10 16:07:20 UTC
*** Bug 468019 has been marked as a duplicate of this bug. ***
Comment 15 postix 2023-04-10 16:07:34 UTC
*** Bug 453990 has been marked as a duplicate of this bug. ***
Comment 16 postix 2023-04-10 16:07:53 UTC
*** Bug 456509 has been marked as a duplicate of this bug. ***
Comment 17 postix 2023-04-10 16:08:10 UTC
*** Bug 458409 has been marked as a duplicate of this bug. ***
Comment 18 postix 2023-04-10 16:09:18 UTC
*** Bug 462872 has been marked as a duplicate of this bug. ***
Comment 19 postix 2023-04-10 16:09:33 UTC
*** Bug 462959 has been marked as a duplicate of this bug. ***
Comment 20 postix 2023-04-10 16:09:45 UTC
*** Bug 464947 has been marked as a duplicate of this bug. ***
Comment 21 David Tonhofer 2023-04-11 14:18:43 UTC
Since postix has marked my report as duplicate, I will repost my way to reproduce reproducibly:

1) Start "Godot"
2) Have a "yellow tooltip" pop up about the window frame (not proper to Godot, but to the window manager) for example, go into the "minimize" button until "minimize" tooltip pops up
3) Move the mouse into the "minimize" tooltip
4) Kwin (not only Akonadi) crashes with segmentation fault. 

running: kwin-wayland-5.27.3-2.fc36

crash function:  QTimer::timeout(QTimer::QPrivateSignal)
Comment 22 MacrosV@Gmail.com 2023-04-13 21:12:29 UTC
*** Bug 468404 has been marked as a duplicate of this bug. ***
Comment 23 Sandro Knauß 2023-04-24 23:28:12 UTC
Git commit 1d9d64ec3cf78dfdddc2239df0d33b08dc442104 by Daniel Vrátil.
Committed on 22/04/2023 at 10:34.
Pushed by carlschwan into branch 'release/23.04'.

Fix crash on server shutdown

When AkonadiServer::quit() is called it clears the vector of existing
connections and destroys them. This can race with a resource disconnecting
or crashing on its own, which then enqueues a singal emission from the
Connection to remove itself from the connections vector as well.

Previously the code assumed the Connection must always exist in the vector
which caused a crash when it did not...surprise surprise.
FIXED-IN: 23.04.1

M  +4    -2    src/server/akonadi.cpp

https://invent.kde.org/pim/akonadi/commit/1d9d64ec3cf78dfdddc2239df0d33b08dc442104