Summary: | Crash (apparently cgroups-related) after some time minimized | ||
---|---|---|---|
Product: | [Applications] plasma-systemmonitor | Reporter: | Bharadwaj Raju <bharadwaj.raju777> |
Component: | general | Assignee: | KSysGuard Developers <ksysguard-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | ahiemstra, kde, nate, plasma-bugs |
Priority: | NOR | Keywords: | drkonqi |
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/libksysguard/commit/1ce85053e45c95ef43f9a0543e2710f33b81e10b | Version Fixed In: | 5.21.3 |
Description
Bharadwaj Raju
2020-12-20 08:31:41 UTC
> The crash can be reproduced every time.
Correction, I can't seem to reliably reproduce now. Can't reproduce under GDB either.
Debugging the coredump in GDB:
(gdb) frame 8
#8 0x00007fb97c361b92 in KSysGuard::CGroupPrivate::ReadPidsRunnable::wait (this=0x0) at /home/bharadwaj/kde/src/libksysguard/processcore/cgroup.cpp:95
95 std::unique_lock<std::mutex> lock{m_lock};
(gdb) print lock
$3 = {_M_device = 0x50, _M_owns = false}
(gdb) print m_lock
Cannot access memory at address 0x50
I think I've found it. This is not thread safe: ``` if (d->readPids) { d->readPids->wait(); } ``` Because in another thread we do: CGroupPrivate::ReadPidsRunnable::run() { .... m_cgroupPrivate->readPids = nullptr; } This could happen between the two lines in the first paste. A possibly relevant merge request was started @ https://invent.kde.org/plasma/libksysguard/-/merge_requests/122 Git commit 18937f39935d3918f427bd8e6487244d0c6acdae by David Edmundson. Committed on 04/03/2021 at 14:16. Pushed by davidedmundson into branch 'master'. Move CGroup pid fetching callback to the controller The CGroup class started out as a dumb data store, that did some fetching of relevant data. It then gained a more complex async operation. The lifepsan of the CGgroup object is managed by the model, so could get deleted whilst the runnable was running. QRunnables and non-qobjects leds to a lot of potential problems. There was a complex mutex and a wait condition, yet it still misses a case only solvable with yet more mutexes. By moving the callback handling logic to the controller, we can guard everything in a safer more Qt manner without any overhead and with simpler code. There is a behavioural change if you call pids whilst things are loading, but given a signal is emitted when pids load that's fine. This class is exported, but the header was never installed. Whilst technically it is an ABI break it pragmantically will have no impact whatsoever. M +11 -39 processcore/cgroup.cpp M +8 -1 processcore/cgroup.h M +5 -2 processcore/cgroup_data_model.cpp https://invent.kde.org/plasma/libksysguard/commit/18937f39935d3918f427bd8e6487244d0c6acdae Git commit 1ce85053e45c95ef43f9a0543e2710f33b81e10b by David Edmundson. Committed on 04/03/2021 at 14:17. Pushed by davidedmundson into branch 'Plasma/5.21'. Move CGroup pid fetching callback to the controller The CGroup class started out as a dumb data store, that did some fetching of relevant data. It then gained a more complex async operation. The lifepsan of the CGgroup object is managed by the model, so could get deleted whilst the runnable was running. QRunnables and non-qobjects leds to a lot of potential problems. There was a complex mutex and a wait condition, yet it still misses a case only solvable with yet more mutexes. By moving the callback handling logic to the controller, we can guard everything in a safer more Qt manner without any overhead and with simpler code. There is a behavioural change if you call pids whilst things are loading, but given a signal is emitted when pids load that's fine. This class is exported, but the header was never installed. Whilst technically it is an ABI break it pragmantically will have no impact whatsoever. (cherry picked from commit 18937f39935d3918f427bd8e6487244d0c6acdae) M +11 -39 processcore/cgroup.cpp M +8 -1 processcore/cgroup.h M +5 -2 processcore/cgroup_data_model.cpp https://invent.kde.org/plasma/libksysguard/commit/1ce85053e45c95ef43f9a0543e2710f33b81e10b |