Skip to content

File descriptor leak via executable DataSource engine causes plasmashell crash #8

@OmerFarukOruc

Description

@OmerFarukOruc

Bug Description

KVitals causes plasmashell to crash repeatedly due to file descriptor (FD) exhaustion. The executable DataSource engine spawns a new QProcess (bash subprocess) every update interval, and the pipe FDs from these processes accumulate faster than they are cleaned up — especially under Wayland.

Once the per-process soft FD limit (typically 1024) is reached, plasmashell can no longer open pipes, shared libraries, or GPU buffers, and crashes with exit code 255.

Crash Sequence (from journalctl)

QProcess: Cannot create pipe (Too many open files)
Cannot load library /usr/lib64/qt6/plugins/...: Too many open files
eglSwapBuffers failed with 0x300c
The Wayland connection experienced a fatal error: Too many open files
plasmashell.service: Main process exited, code=exited, status=255/EXCEPTION

Root Cause

In main.qml:

Plasma5Support.DataSource {
    engine: "executable"
    connectedSources: ["bash " + scriptPath + " " + root.networkInterface]
    interval: Plasmoid.configuration.updateInterval
}

Each tick spawns a new bash process via QProcess, which creates 3+ pipe FDs (stdin/stdout/stderr). The script sys-stats.sh then forks ~15 additional subprocesses (awk x8, cat x3, free, grep, date, bc), each with their own FDs.

At the default 2-second interval, that is ~20+ pipe FDs created every 2 seconds. Under Wayland, QProcess cleanup can lag, causing FDs to accumulate until the soft limit (1024) is hit — typically within minutes.

Environment

  • OS: Fedora 43 (KDE Plasma Desktop Edition)
  • Plasma: 6.6.0
  • Session: Wayland
  • Widget version: Latest from GitHub (as of Feb 2026)

Reproduction

  1. Install kvitals with default settings (2s update interval)
  2. Start a Wayland session
  3. Monitor FDs: watch -n 5 'ls /proc/$(pgrep -n plasmashell)/fd | wc -l'
  4. Observe FD count climbing steadily
  5. plasmashell crashes once it reaches ~1024 FDs

Suggested Fix

Replace engine: "executable" with KDE's native SystemMonitor DataSource (org.kde.ksystemstats), which provides CPU, RAM, temperature, battery, and network data without spawning any subprocesses.

Example:

import org.kde.ksystemstats as KSysStats

KSysStats.SensorDataModel {
    sensors: ["cpu/all/usage", "memory/physical/used", "memory/physical/total"]
}

This approach:

  • Uses zero subprocesses — reads kernel data directly via D-Bus
  • Creates zero pipe FDs — no QProcess involved
  • Is the recommended KDE approach for system monitoring widgets

Alternatively, reading /proc/stat, /proc/meminfo, /sys/class/thermal/, etc. directly from QML via Qt.labs.platform file I/O would also eliminate the subprocess spawning.

Workaround

Users can mitigate the crash by raising plasmashell's soft FD limit:

mkdir -p ~/.config/systemd/user/plasma-plasmashell.service.d/
cat > ~/.config/systemd/user/plasma-plasmashell.service.d/override.conf << 'EOF'
[Service]
LimitNOFILESoft=65536
EOF
systemctl --user daemon-reload && systemctl --user restart plasma-plasmashell.service

This raises the limit from 1024 to 65536, buying significant headroom but not fixing the underlying leak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions