Bug 459130

Summary: Monitoring crashes when there are offline CPU cores
Product: [Applications] plasma-systemmonitor Reporter: johnchen40904
Component: generalAssignee: KSysGuard Developers <ksysguard-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: ahiemstra, nate, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.25.4   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.27
Sentry Crash Report:
Attachments: A modified page which shows the non functioning graphs (This is a 8-core system with 4 cores disabled), also htop which successfully recognized these cores as "offline".

Description johnchen40904 2022-09-15 02:02:32 UTC
Created attachment 152067 [details]
A modified page which shows the non functioning graphs (This is a 8-core system with 4 cores disabled), also htop which successfully recognized these cores as "offline".

SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Open a superuser terminal.
2. Set a CPU core offline by entering: "echo 0 > /sys/devices/system/cpu/cpu1/online" (This disables the second core of the CPU)
3. Open System Monitor

OBSERVED RESULT
All pages except "Processes" stops functioning, components showing blank charts everywhere. Persists after application relaunch.

EXPECTED RESULT
Components that aren't CPU related keep functioning, while multicore CPU charts should show "Offline" on these cores (or simply hide them from view)

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Fedora Linux 35 (KDE Plasma) x86_64
(available in About System)
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2022-09-29 12:53:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/42
Comment 2 Arjen Hiemstra 2023-01-11 11:30:31 UTC
Git commit fda80732b5953d2b554864d34149966297ebe84d by Arjen Hiemstra.
Committed on 11/01/2023 at 11:00.
Pushed by ahiemstra into branch 'master'.

cpu: Account for offline processors when adding CPU objects

Processors can be marked as offline. In that case, they will not be
reported by /proc/cpuinfo . However, the processor ID in /proc/stat will
account for the missing processor. In that case, we end up trying to
perform an out of bounds read on the vector of CPU objects.

To account for missing processors, store the CPU objects in a hash
rather than a vector so that we can store them based on the actual
processor ID. In addition, rework the naming so we report a more proper
core name if cores are offline.

M  +4    -4    plugins/cpu/linuxcpu.cpp
M  +4    -3    plugins/cpu/linuxcpu.h
M  +44   -12   plugins/cpu/linuxcpuplugin.cpp
M  +2    -2    plugins/cpu/linuxcpuplugin.h

https://invent.kde.org/plasma/ksystemstats/commit/fda80732b5953d2b554864d34149966297ebe84d