Bug 514580

Summary: ksystemstats_intel_helper crashes with SIGFPE (division by zero) on Intel GPU
Product: [Frameworks and Libraries] ksystemstats Reporter: access <jevgeni.kostenko+kde.org>
Component: GeneralAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: ahiemstra, nate, nicolas.fella
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Crash is caused by unguarded division in IntelHelper.cpp: engineCounters[...] / enginesPerClass[...] enginesPerClass[...] can be zero on some systems, causing SIGFPE. A minimal patch is attached
Optional helper script used on Arch Linux to reproduce and validate the fix. Not intended for upstream inclusion.

Description access 2026-01-14 10:06:22 UTC
Created attachment 188503 [details]
Crash is caused by unguarded division in IntelHelper.cpp:  engineCounters[...] / enginesPerClass[...]  enginesPerClass[...] can be zero on some systems, causing SIGFPE.  A minimal patch is attached

SUMMARY
ksystemstats_intel_helper crashes with SIGFPE (division by zero) on Intel GPU

STEPS TO REPRODUCE
1. Use an Intel GPU where some engine classes report zero engines
2. Start Plasma or any component using ksystemstats (e.g. System Monitor widgets)
3. ksystemstats_intel_helper crashes immediately

OBSERVED RESULT
ksystemstats_intel_helper crashes with SIGFPE due to division by zero.
As a result, GPU statistics stop working.

EXPECTED RESULT
ksystemstats_intel_helper should not crash when enginesPerClass[] is zero.
It should safely handle missing or unsupported engine classes.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.5.5
KDE Frameworks Version: 6.22.0
Qt Version: 6.10.x

ADDITIONAL INFORMATION
Crash happens in ksystemstats_intel_helper (Plasma system statistics backend), not in plasmashell UI itself.

Root cause:
Unconditional division by enginesPerClass[] without checking for zero.

A tested fix is to guard all divisions, e.g.:

engineCounters[class] / enginesPerClass[class]
→
enginesPerClass[class] ? (engineCounters[class] / enginesPerClass[class]) : 0

Patch tested locally, fully resolves the crash.
Comment 1 access 2026-01-14 10:17:51 UTC
Created attachment 188505 [details]
Optional helper script used on Arch Linux to reproduce and validate the fix. Not intended for upstream inclusion.

Optional helper script used on Arch Linux to reproduce and validate the fix. Not intended for upstream inclusion.
Comment 2 Nicolas Fella 2026-01-14 13:54:41 UTC

*** This bug has been marked as a duplicate of bug 514305 ***
Comment 3 access 2026-01-14 14:47:51 UTC
**SUMMARY**
`ksystemstats_intel_helper` crashes with SIGFPE (division by zero) on Intel iGPU. Root cause is unguarded division by `enginesPerClass[...]` which can be 0 on some systems.

**DETAILS / ROOT CAUSE**
Crash happens in `plugins/gpu/IntelHelper.cpp` when printing per-engine utilization:
`engineCounters[class] / enginesPerClass[class]`
`enginesPerClass[...]` may be zero => SIGFPE.

Related report with similar crash log / minimal info:
[https://bugs.kde.org/show_bug.cgi?id=514305](https://bugs.kde.org/show_bug.cgi?id=514305)

**WORKAROUND / FIX**
I have a minimal patch that guards the divisions (fallback to 0 when `enginesPerClass[...] == 0`).
After applying it, `plasma-ksystemstats.service` stops crashing and GPU sensors start working correctly.

**USER-VISIBLE EFFECT**
After the fix:

* GPU sensors/graphs in Plasma System Monitor work correctly
* GPU graphs in Plasma widgets also start updating normally

**ATTACHMENTS**

* `fix-intel-helper-fpe.patch` — minimal source patch (guarded division)
* `ksystemstats-intel-fpe-fix.sh` — reproducible helper script to build/reinstall patched package (Arch packaging workflow)
* `ksystemstats_intel_helper_SIGFPE.txt` — crash details (SIGFPE)

(If needed I can provide additional backtrace with debug symbols, but this looks deterministic and the patch is trivial.)
Comment 4 Nate Graham 2026-01-16 18:18:44 UTC
If you can provide a patch, that would be great, thanks! Please submit send it to https://invent.kde.org/plasma/ksystemstats/-/merge_requests/

*** This bug has been marked as a duplicate of bug 514305 ***