<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>495524</bug_id>
          
          <creation_ts>2024-10-29 10:11:11 +0000</creation_ts>
          <short_desc>Support CPU stats with RK3588 and other ARM CPUs</short_desc>
          <delta_ts>2024-11-13 13:20:50 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>Frameworks and Libraries</classification>
          <product>ksystemstats</product>
          <component>General</component>
          <version>6.2.2</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>crash</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jonathan L Hanmann">jhanmann</reporter>
          <assigned_to name="Plasma Bugs List">plasma-bugs-null</assigned_to>
          <cc>ahiemstra</cc>
    
    <cc>aykevanlaethem</cc>
    
    <cc>janne-kde</cc>
    
    <cc>josh</cc>
    
    <cc>m.kurz</cc>
    
    <cc>nate</cc>
          
          <cf_commitlink>https://invent.kde.org/plasma/ksystemstats/-/commit/23f8291aec1c1123e240187280174c336dc9df57</cf_commitlink>
          <cf_versionfixedin>6.2.4</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2370136</commentid>
    <comment_count>0</comment_count>
      <attachid>175330</attachid>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-10-29 10:11:11 +0000</bug_when>
    <thetext>Created attachment 175330
Patch to make cpu information available

SUMMARY

Left over issue after fix for crash in commit #c5bc0067b31f6c2bdee127702c6cc4717c770808. There is no no crash, and while this is great, the cpu stats are still missing. The attached patch corrects this problem but you may prefer a different solution based on your knowledge of the code.

While I&apos;ve tested this only on a Rock-5b my examination of the /proc/cpuinfo on an Odroid N2+ and a Raspberry Pi 4b+ indicates the same missing physical ID that is at least one source of the problem. I added more conditionals to my patch to be somewhat comprehensive and may have overdone it but it works.

STEPS TO REPRODUCE
1. Build latest ksystemstats
2. Try to view cpu stats on Rock-5b running latest kernel with Noble.

OBSERVED RESULT

No available CPU stats.

EXPECTED RESULT

CPU stats to choose for graphs.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma:  Linux rock-5b-3 6.1.75-vendor-rk35xx
KDE Plasma Version: 6.2.80
KDE Frameworks Version: 6.8.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370401</commentid>
    <comment_count>1</comment_count>
    <who name="Janne Grunau">janne-kde</who>
    <bug_when>2024-10-30 07:52:01 +0000</bug_when>
    <thetext>wishlist doesn&apos;t seem the appropriate priority as this avoids crashes on all or many non-x86 systems. That is systems without &quot;physical id&quot; in `/proc/cpuinfo`. See below for a single CPU core entry from a Apple M1 Ultra:
&gt; processor       : 0
&gt; BogoMIPS        : 48.00
&gt; Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm ssbs sb paca pacg dcpodp flagm2 frint
&gt; CPU implementer : 0x61
&gt; CPU architecture: 8
&gt; CPU variant     : 0x2
&gt; CPU part        : 0x028
&gt; CPU revision    : 0

It prevents a nullptr dereference in `LinuxCpuPluginPrivate::update()` when the constructor skipped all CPUs.

Backtrace:
&gt; #0  __pthread_kill_implementation (threadid=281470396449024, signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
&gt; #1  0x0000fffeee2e8850 [PAC] in __pthread_kill_internal (threadid=&lt;optimized out&gt;, signo=11) at pthread_kill.c:78
&gt; #2  0x0000fffeee295a00 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
&gt; #3  0x0000fffeef062adc [PAC] in KCrash::defaultCrashHandler (sig=11) at /usr/src/debug/kf6-kcrash-6.7.0-1.fc40.aarch64/src/kcrash.cpp:596
&gt; #4  0x0000fffeef104840 [PAC] in &lt;signal handler called&gt; ()
&gt; #5  0x0000fffeef00b820 in KSysGuard::SensorObject::isSubscribed (this=this@entry=0x0) at /usr/include/c++/14/bits/unique_ptr.h:193
&gt; #6  0x0000fffee921b5bc [PAC] in LinuxCpuObject::update (this=0x0, system=341648, user=427329, wait=15886, idle=78750572) at /usr/src/debug/ksystemstats-6.2.1-1.fc40.aarch64/plugins/cpu/linuxcpu.cpp:63
&gt; #7  LinuxCpuPluginPrivate::update (this=0xaaab5a9eaf50) at /usr/src/debug/ksystemstats-6.2.1-1.fc40.aarch64/plugins/cpu/linuxcpuplugin.cpp:163
&gt; #8  0x0000aaab4d535f80 [PAC] in Daemon::sendFrame() ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370477</commentid>
    <comment_count>2</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2024-10-30 14:57:28 +0000</bug_when>
    <thetext>If it actually crashes, that does raise the priority.

Since you&apos;ve got a patch, would you like to submit it at https://invent.kde.org/plasma/ksystemstats/-/merge_requests ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370507</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-10-30 15:31:28 +0000</bug_when>
    <thetext>(In reply to Nate Graham from comment #2)
&gt; If it actually crashes, that does raise the priority.
&gt; 
&gt; Since you&apos;ve got a patch, would you like to submit it at
&gt; https://invent.kde.org/plasma/ksystemstats/-/merge_requests ?

Sure. I will do that. My apologies for not responding more promptly to the original crash fix. I was traveling and unable to test it until returning. That is when I noticed it was incomplete (at least in my own view) since it only fixed the original crash and not the physical ID issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370511</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-10-30 15:34:20 +0000</bug_when>
    <thetext>(In reply to Jonathan L Hanmann from comment #3)
&gt; (In reply to Nate Graham from comment #2)
&gt; &gt; If it actually crashes, that does raise the priority.
&gt; &gt; 
&gt; &gt; Since you&apos;ve got a patch, would you like to submit it at
&gt; &gt; https://invent.kde.org/plasma/ksystemstats/-/merge_requests ?
&gt; 
&gt; Sure. I will do that. My apologies for not responding more promptly to the
&gt; original crash fix. I was traveling and unable to test it until returning.
&gt; That is when I noticed it was incomplete (at least in my own view) since it
&gt; only fixed the original crash and not the physical ID issue.

Actually, perhaps you didn&apos;t mean me? I don&apos;t have a user setup for our gitlab being just an ordinary user?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370512</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-10-30 15:34:32 +0000</bug_when>
    <thetext>(In reply to Jonathan L Hanmann from comment #3)
&gt; (In reply to Nate Graham from comment #2)
&gt; &gt; If it actually crashes, that does raise the priority.
&gt; &gt; 
&gt; &gt; Since you&apos;ve got a patch, would you like to submit it at
&gt; &gt; https://invent.kde.org/plasma/ksystemstats/-/merge_requests ?
&gt; 
&gt; Sure. I will do that. My apologies for not responding more promptly to the
&gt; original crash fix. I was traveling and unable to test it until returning.
&gt; That is when I noticed it was incomplete (at least in my own view) since it
&gt; only fixed the original crash and not the physical ID issue.

Actually, perhaps you didn&apos;t mean me? I don&apos;t have a user setup for our gitlab being just an ordinary user?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370513</commentid>
    <comment_count>6</comment_count>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-10-30 15:36:45 +0000</bug_when>
    <thetext>(In reply to Jonathan L Hanmann from comment #5)
&gt; (In reply to Jonathan L Hanmann from comment #3)
&gt; &gt; (In reply to Nate Graham from comment #2)
&gt; &gt; &gt; If it actually crashes, that does raise the priority.
&gt; &gt; &gt; 
&gt; &gt; &gt; Since you&apos;ve got a patch, would you like to submit it at
&gt; &gt; &gt; https://invent.kde.org/plasma/ksystemstats/-/merge_requests ?
&gt; &gt; 
&gt; &gt; Sure. I will do that. My apologies for not responding more promptly to the
&gt; &gt; original crash fix. I was traveling and unable to test it until returning.
&gt; &gt; That is when I noticed it was incomplete (at least in my own view) since it
&gt; &gt; only fixed the original crash and not the physical ID issue.
&gt; 
&gt; Actually, perhaps you didn&apos;t mean me? I don&apos;t have a user setup for our
&gt; gitlab being just an ordinary user?

Nevermind, I should have spend a few more seconds looking at it. I will register and submit the patch. Sorry for the spam...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370535</commentid>
    <comment_count>7</comment_count>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-10-30 15:56:43 +0000</bug_when>
    <thetext>(In reply to Jonathan L Hanmann from comment #6)
&gt; (In reply to Jonathan L Hanmann from comment #5)
&gt; &gt; (In reply to Jonathan L Hanmann from comment #3)
&gt; &gt; &gt; (In reply to Nate Graham from comment #2)
&gt; &gt; &gt; &gt; If it actually crashes, that does raise the priority.
&gt; &gt; &gt; &gt; 
&gt; &gt; &gt; &gt; Since you&apos;ve got a patch, would you like to submit it at
&gt; &gt; &gt; &gt; https://invent.kde.org/plasma/ksystemstats/-/merge_requests ?
&gt; &gt; &gt; 
&gt; &gt; &gt; Sure. I will do that. My apologies for not responding more promptly to the
&gt; &gt; &gt; original crash fix. I was traveling and unable to test it until returning.
&gt; &gt; &gt; That is when I noticed it was incomplete (at least in my own view) since it
&gt; &gt; &gt; only fixed the original crash and not the physical ID issue.
&gt; &gt; 
&gt; &gt; Actually, perhaps you didn&apos;t mean me? I don&apos;t have a user setup for our
&gt; &gt; gitlab being just an ordinary user?
&gt; 
&gt; Nevermind, I should have spend a few more seconds looking at it. I will
&gt; register and submit the patch. Sorry for the spam...

Oh my. :-( I just got this response to my email.

Unfortunately, your email message to GitLab could not be processed. 
You are not allowed to perform this action. If you believe this is in error, contact a staff member.

I thought I did it correctly and used the email addresss the GitLab system provided to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370612</commentid>
    <comment_count>8</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2024-10-30 20:33:14 +0000</bug_when>
    <thetext>You have to set up an account on our Gitlab instance (invent.kde.org), fork the relevant repo, and send a merge request from your fork. Very similar to the standard Github workflow. Our docs can be found here: https://community.kde.org/Infrastructure/GitLab</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2370617</commentid>
    <comment_count>9</comment_count>
    <who name="Bug Janitor Service">bug-janitor</who>
    <bug_when>2024-10-30 21:07:02 +0000</bug_when>
    <thetext>A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/92</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2371647</commentid>
    <comment_count>10</comment_count>
    <who name="">m.kurz</who>
    <bug_when>2024-11-04 09:49:16 +0000</bug_when>
    <thetext>I am on Asahi Linux (Arch linux ARM) and ksystemstats crashes for me (using v6.2.2).
With the patch in https://invent.kde.org/plasma/ksystemstats/-/merge_requests/92 it no longer crashes.
There was a chat about this also in the Asahi IRC: https://oftc.irclog.whitequark.org/asahi/2024-10-29#1730241059-1730242297

Can the merge request please be reviewed/merged and backported to branch Plasma/6.2?

Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2371660</commentid>
    <comment_count>11</comment_count>
    <who name="">m.kurz</who>
    <bug_when>2024-11-04 11:17:06 +0000</bug_when>
    <thetext>I see that Plasma 6.2.3 is due tomorrow (Tue 2024-11-05 according to https://community.kde.org/Schedules/Plasma_6#Future_releases) Would be nice if you can take a look at this before...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2371701</commentid>
    <comment_count>12</comment_count>
    <who name="Jonathan L Hanmann">jhanmann</who>
    <bug_when>2024-11-04 14:36:41 +0000</bug_when>
    <thetext>(In reply to m.kurz from comment #11)
&gt; I see that Plasma 6.2.3 is due tomorrow (Tue 2024-11-05 according to
&gt; https://community.kde.org/Schedules/Plasma_6#Future_releases) Would be nice
&gt; if you can take a look at this before...

I did provide the requested merge request. I believe you know that since I saw your comment on that request. It appears to be in the pipeline. I don&apos;t believe there is anything more I can do to assist or expedite this but wanted to respond just in case I was supposed to do something else. I wouldn&apos;t want to ignore something and be the delaying factor.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2373330</commentid>
    <comment_count>13</comment_count>
    <who name="">m.kurz</who>
    <bug_when>2024-11-11 08:54:43 +0000</bug_when>
    <thetext>*** Bug 494915 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2373940</commentid>
    <comment_count>14</comment_count>
    <who name="Bug Janitor Service">bug-janitor</who>
    <bug_when>2024-11-13 13:06:16 +0000</bug_when>
    <thetext>A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/93</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2373943</commentid>
    <comment_count>15</comment_count>
    <who name="Hector Martin">marcan</who>
    <bug_when>2024-11-13 13:17:16 +0000</bug_when>
    <thetext>Git commit 2f0903224c21e9e1107063d3ae4adabed25f555b by Hector Martin.
Committed on 13/11/2024 at 13:12.
Pushed by redstrate into branch &apos;master&apos;.

plugins/cpu: Test for the proper CPU property, skip nonexistent CPUs

Commit 478e766d19b3 regressed ksystemstats on many ARM systems, since it
mistakenly tests the &quot;cpu&quot; property of the CPU object (which is is the
&quot;physical id&quot;) and not the &quot;id&quot; property (which is the actual CPU
number). For systems without a &quot;physical id&quot;, this ignores all CPUs and
ends up crashing on a NULL deref later when it tries to look up CPU
numbers from /proc/stat.

Fix the incorrect check and add an extra NULL guard, so if we fail to
parse /proc/cpuinfo properly we don&apos;t crash. We only need an &quot;id&quot;
property to consider the CPU object valid, and that property is required
to identify the CPU in the first place, so it is the only one that needs
to be tested.

Also guard insertion into m_cpusBySystemIds if the keys do not exist
(this is what wants `cpu` and `core`). This isn&apos;t strictly necessary,
but more correct. Consumers of that already test for entries correctly
and don&apos;t segfault if missing.
Fixes: 478e766d19b3 (&quot;plugins/cpu: Ignore invalid CPU info when reading /proc/cpuinfo&quot;)

M  +10   -4    plugins/cpu/linuxcpuplugin.cpp

https://invent.kde.org/plasma/ksystemstats/-/commit/2f0903224c21e9e1107063d3ae4adabed25f555b</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2373944</commentid>
    <comment_count>16</comment_count>
    <who name="Joshua Goins">josh</who>
    <bug_when>2024-11-13 13:20:50 +0000</bug_when>
    <thetext>Git commit 23f8291aec1c1123e240187280174c336dc9df57 by Joshua Goins, on behalf of Hector Martin.
Committed on 13/11/2024 at 13:17.
Pushed by redstrate into branch &apos;Plasma/6.2&apos;.

plugins/cpu: Test for the proper CPU property, skip nonexistent CPUs

Commit 478e766d19b3 regressed ksystemstats on many ARM systems, since it
mistakenly tests the &quot;cpu&quot; property of the CPU object (which is is the
&quot;physical id&quot;) and not the &quot;id&quot; property (which is the actual CPU
number). For systems without a &quot;physical id&quot;, this ignores all CPUs and
ends up crashing on a NULL deref later when it tries to look up CPU
numbers from /proc/stat.

Fix the incorrect check and add an extra NULL guard, so if we fail to
parse /proc/cpuinfo properly we don&apos;t crash. We only need an &quot;id&quot;
property to consider the CPU object valid, and that property is required
to identify the CPU in the first place, so it is the only one that needs
to be tested.

Also guard insertion into m_cpusBySystemIds if the keys do not exist
(this is what wants `cpu` and `core`). This isn&apos;t strictly necessary,
but more correct. Consumers of that already test for entries correctly
and don&apos;t segfault if missing.
Fixes: 478e766d19b3 (&quot;plugins/cpu: Ignore invalid CPU info when reading /proc/cpuinfo&quot;)
(cherry picked from commit 2f0903224c21e9e1107063d3ae4adabed25f555b)

M  +10   -4    plugins/cpu/linuxcpuplugin.cpp

https://invent.kde.org/plasma/ksystemstats/-/commit/23f8291aec1c1123e240187280174c336dc9df57</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>175330</attachid>
            <date>2024-10-29 10:11:11 +0000</date>
            <delta_ts>2024-10-29 10:11:11 +0000</delta_ts>
            <desc>Patch to make cpu information available</desc>
            <filename>ksystemstats-fix-cpuinfo-for-arm.patch</filename>
            <type>text/plain</type>
            <size>759</size>
            <attacher name="Jonathan L Hanmann">jhanmann</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL3BsdWdpbnMvY3B1L2xpbnV4Y3B1cGx1Z2luLmNwcCBiL3BsdWdpbnMvY3B1
L2xpbnV4Y3B1cGx1Z2luLmNwcAppbmRleCBhN2VmMGZhLi4xZWQ0ZGJmIDEwMDY0NAotLS0gYS9w
bHVnaW5zL2NwdS9saW51eGNwdXBsdWdpbi5jcHAKKysrIGIvcGx1Z2lucy9jcHUvbGludXhjcHVw
bHVnaW4uY3BwCkBAIC05OCw3ICs5OCwxMSBAQCBMaW51eENwdVBsdWdpblByaXZhdGU6OkxpbnV4
Q3B1UGx1Z2luUHJpdmF0ZShDcHVQbHVnaW4gKnEpCiAgICAgICAgIC8vIElmIHdlIGRvbid0IGhh
dmUgYSB2YWxpZCBJRCwgY29uc2lkZXIgdGhlIGVudGlyZSBDUFUgaW5mbyB0byBiZSBpbnZhbGlk
LgogICAgICAgICAvLyBUaGlzIG1haW5seSBoYXBwZW5zIHdoZW4gdGhlcmUgaXMgYWRkaXRpb25h
bCBub24tY29yZSByZWxhdGVkIGRhdGEgaW4KICAgICAgICAgLy8gL3Byb2MvY3B1aW5mby4KLSAg
ICAgICAgaWYgKGluZm8uY3B1ICE9IC0xKSB7CisgICAgICAgIGlmICgoaW5mby5pZCAhPSAtMSkg
fHwKKyAgICAgICAgICAgIChpbmZvLmNwdSAhPSAtMSkgfHwKKyAgICAgICAgICAgIChpbmZvLmNv
cmUgIT0gLTEpIHx8CisgICAgICAgICAgICAoaW5mby5mcmVxdWVuY3kgIT0gMCkgfHwKKyAgICAg
ICAgICAgIChpbmZvLnNpYmxpbmdzICE9IC0xKSkgewogICAgICAgICAgICAgY3B1cy5wdXNoX2Jh
Y2soaW5mbyk7CiAgICAgICAgICAgICBjcHVDb3VudCA9IHN0ZDo6bWF4KGNwdUNvdW50LCBpbmZv
LmNwdSk7CiAgICAgICAgIH0K
</data>

          </attachment>
      

    </bug>

</bugzilla>