Bug 442023 - ksystemstats crashes on startup
Summary: ksystemstats crashes on startup
Status: RESOLVED FIXED
Alias: None
Product: ksysguard
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: KSysGuard Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-05 07:29 UTC by Luca Beltrame
Modified: 2021-09-08 17:33 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.23
Sentry Crash Report:


Attachments
Backtrace of the crash (2.08 KB, text/plain)
2021-09-05 07:29 UTC, Luca Beltrame
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Beltrame 2021-09-05 07:29:51 UTC
Created attachment 141307 [details]
Backtrace of the crash

SUMMARY

(Note: ksystemstats doesn't have its own bug component)

Since https://invent.kde.org/plasma/ksystemstats/-/merge_requests/9, ksystemstats crashes at startup in GpuDevice::initialize.

I assume this has to do with the discovery of GPUs which goes awry (see attached backtrace).

STEPS TO REPRODUCE

1. Run ksystemstats

OBSERVED RESULT

ksystemstats crashes on startup

EXPECTED RESULT

ksystemstats should run.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: latest master
(available in About System)
KDE Plasma Version: latest master
KDE Frameworks Version: latest master
Qt Version: 5.15.2 + KDE patches

ADDITIONAL INFORMATION

sudo lshw -c display
  *-display                 
       description: VGA compatible controller
       product: Vega 10 XL/XT [Radeon RX Vega 56/64]
       vendor: Advanced Micro Devices, Inc. [AMD/ATI]
       physical id: 0
       bus info: pci@0000:0b:00.0
       logical name: /dev/fb0
       version: c3
       width: 64 bits
       clock: 33MHz
       capabilities: pm pciexpress msi vga_controller bus_master cap_list rom fb
       configuration: depth=32 driver=amdgpu latency=0 resolution=2560,1440
       resources: irq:110 memory:e0000000-efffffff memory:f0000000-f01fffff ioport:d000(size=256) memory:f6a00000-f6a7ffff memory:c0000-dffff
Comment 1 David Edmundson 2021-09-05 14:50:42 UTC
Pasting inline for search

#0  0x00007ffff79dffc9 in operator==(QString const&, QString const&) () from /lib64/libQt5Core.so.5
#1  0x00007ffff7ed5c39 in KSysGuard::SensorProperty::setName (this=0x7ffff7640a60 <main_arena+96>, name=...) at /usr/src/debug/libksysguard5-5.22.80git.20210904T011806~8247320-ku.38.1.x86_64/systemstats/SensorProperty.cpp:71
#2  0x00007ffff340a53b in GpuDevice::initialize (this=0x5555556de740) at /usr/src/debug/ksystemstats5-5.22.80git.20210903T113040~ede1aab-ku.22.3.x86_64/plugins/gpu/GpuDevice.cpp:49
#3  0x00007ffff340b164 in LinuxAmdGpu::initialize (this=0x5555556de740) at /usr/src/debug/ksystemstats5-5.22.80git.20210903T113040~ede1aab-ku.22.3.x86_64/plugins/gpu/LinuxAmdGpu.cpp:56
#4  0x00007ffff340c71f in LinuxBackend::start (this=0x5555556cc9e0) at /usr/src/debug/ksystemstats5-5.22.80git.20210903T113040~ede1aab-ku.22.3.x86_64/plugins/gpu/LinuxBackend.cpp:64
#5  0x00007ffff3409770 in GpuPlugin::GpuPlugin (args=..., parent=0x7fffffffd338, this=0x5555556cba90) at /usr/src/debug/ksystemstats5-5.22.80git.20210903T113040~ede1aab-ku.22.3.x86_64/plugins/gpu/GpuPlugin.cpp:44
#6  KPluginFactory::createInstance<GpuPlugin, QObject> (parentWidget=<optimized out>, parent=<optimized out>, args=...) at /usr/include/KF5/KCoreAddons/kpluginfactory.h:806
Comment 2 Luca Beltrame 2021-09-05 15:37:18 UTC
It looks like the sensor property is constructed improperly (garbage when trying to check it from gdb), but I'm not sure how to debug this further.
Comment 3 Luca Beltrame 2021-09-05 15:43:09 UTC
By sensor property I mean m_temperatureProperty in plugins/gpu/GpuDevice.cpp.
Comment 4 Fabian Vogt 2021-09-05 16:24:25 UTC
FWICT, the issue is that m_temperatureProperty and the other members are never initialized, so the check for nullptr in LinuxAmdGpu::makeSensors also fails.

Does it work with the following change?

diff --git a/plugins/gpu/GpuDevice.h b/plugins/gpu/GpuDevice.h
index 18ddedc..1450d9f 100644
--- a/plugins/gpu/GpuDevice.h
+++ b/plugins/gpu/GpuDevice.h
@@ -28,7 +28,7 @@ protected:
     KSysGuard::SensorProperty *m_usageProperty;
     KSysGuard::SensorProperty *m_totalVramProperty;
     KSysGuard::SensorProperty *m_usedVramProperty;
-    KSysGuard::SensorProperty *m_temperatureProperty;
+    KSysGuard::SensorProperty *m_temperatureProperty = nullptr;
     KSysGuard::SensorProperty *m_coreFrequencyProperty;
     KSysGuard::SensorProperty *m_memoryFrequencyProperty;
 };
Comment 5 Luca Beltrame 2021-09-05 16:31:40 UTC
This at least prevents ksystemstats from crashing. There's another issue now which I'll report a separate bug for later.
Comment 6 David Edmundson 2021-09-06 10:25:02 UTC
It's a bit weird that we have a member in the superclass that's created in the subclass overriding the superclass creation of it.

But for the design we have, the patch looks sane.
Comment 7 Bug Janitor Service 2021-09-06 12:18:03 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/18
Comment 8 David Edmundson 2021-09-06 12:19:14 UTC
Git commit 207b8960a6fcd531584283f9475081d2dcf0f4aa by David Edmundson.
Committed on 06/09/2021 at 12:16.
Pushed by davidedmundson into branch 'master'.

[plugins/gpu] Initialise properties

Properties are created in the relevant subclass via makeSensors. If an
implementation fails to create an object we don't want dangling
pointers.

M  +7    -7    plugins/gpu/GpuDevice.h

https://invent.kde.org/plasma/ksystemstats/commit/207b8960a6fcd531584283f9475081d2dcf0f4aa