https://bugs.kde.org/show_bug.cgi?id=522606

            Bug ID: 522606
           Summary: # KDE Connect (kdeconnectd) 100% Core Usage CPU Spin
                    on Disconnect
    Classification: Applications
           Product: kdeconnect
      Version First unspecified
       Reported In:
          Platform: Neon
                OS: Linux
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: desktop-application
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 194000
  --> https://bugs.kde.org/attachment.cgi?id=194000&action=edit
summarised by CLAUDE + my screenshots

# KDE Connect (kdeconnectd) 100% Core Usage CPU Spin on Disconnect

**Product**: kdeconnect
**Component**: kdeconnectd
**Version**: (Plasma 6.x / KF6)
**Platform**: Linux (Wayland/X11)

### Description
`kdeconnectd` consumes exactly 1 CPU core (12.5% on an 8-core system)
continuously in an infinite loop. This occurs when a connected device link is
destroyed or disconnected, causing the SFTP plugin (`kdeconnect_sftp.so`) to
violently loop while handling `KFilePlacesModel` updates and parsing an IP
address via `QUrl::setHost()`.

### Steps to Reproduce (Presumed)
1. Pair a device (Android/iOS) with KDE Connect.
2. Expose a filesystem/mount via SFTP.
3. Abruptly drop the device connection (e.g., WiFi drops, suspend, or
aggressive firewall). "My phone sleeping 8h for disactivity"
4. `kdeconnectd` gets stuck in a 100% CPU thread loop.

### Backtrace of the Spinning Thread
The main thread is caught spinning inside `Device::reloadPlugins()` triggered
by `Device::linkDestroyed`.

```text
Thread 1 (Thread 0x752c100f6e00 (LWP 50101) "kdeconnectd"):
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:77
#1  ??? () at /lib/x86_64-linux-gnu/libQt6Core.so.6
#2  QIPAddressUtils::parseIp4(unsigned int&, QChar const*, QChar const*) () at
/lib/x86_64-linux-gnu/libQt6Core.so.6
#3  ??? () at /lib/x86_64-linux-gnu/libQt6Core.so.6
#4  QUrl::setHost(QString const&, QUrl::ParsingMode) () at
/lib/x86_64-linux-gnu/libQt6Core.so.6
#5  ??? () at /lib/x86_64-linux-gnu/libKF6KIOFileWidgets.so.6
#6  ??? () at /lib/x86_64-linux-gnu/libKF6KIOFileWidgets.so.6
#7  KFilePlacesModel::data(QModelIndex const&, int) const () at
/lib/x86_64-linux-gnu/libKF6KIOFileWidgets.so.6
#8  KFilePlacesModel::url(QModelIndex const&) const () at
/lib/x86_64-linux-gnu/libKF6KIOFileWidgets.so.6
#9  ??? () at
/usr/lib/x86_64-linux-gnu/qt6/plugins/kdeconnect/kdeconnect_sftp.so
#10 ??? () at
/usr/lib/x86_64-linux-gnu/qt6/plugins/kdeconnect/kdeconnect_sftp.so
#11 ??? () at
/usr/lib/x86_64-linux-gnu/qt6/plugins/kdeconnect/kdeconnect_sftp.so
#12 ??? () at /lib/x86_64-linux-gnu/libkdeconnectcore.so.26
#13 ??? () at /lib/x86_64-linux-gnu/libkdeconnectcore.so.26
#14 Device::reloadPlugins() () at /lib/x86_64-linux-gnu/libkdeconnectcore.so.26
#15 Device::removeLink(DeviceLink*) () at
/lib/x86_64-linux-gnu/libkdeconnectcore.so.26
#16 Device::linkDestroyed(QObject*) () at
/lib/x86_64-linux-gnu/libkdeconnectcore.so.26
#17 ??? () at /lib/x86_64-linux-gnu/libkdeconnectcore.so.26
#18 ??? () at /lib/x86_64-linux-gnu/libkdeconnectcore.so.26
```

### Analysis
When `DeviceLink` is destroyed, `Device::removeLink` calls `reloadPlugins()`.
The `kdeconnect_sftp.so` attempts to clean up its SFTP mount state by querying
`KFilePlacesModel`. 
For some reason (possibly a malformed URL left behind by the dropped
connection, or a signal/slot feedback loop), it continuously calls
`KFilePlacesModel::url()`, which forces `QUrl::setHost()` to endlessly parse a
broken IP address via `QIPAddressUtils::parseIp4`. This results in the thread
pinning a CPU core at 100%.

**Critical Symptom:** Because the infinite loop happens on the main thread, the
primary Qt event loop is completely blocked. This starves the DBus interface.
As a result, if the user opens the KDE Connect Settings GUI during this glitch,
the GUI fails to fetch data via DBus—showing a blank "Device name" and
completely empty lists of paired devices and plugins. Restarting `kdeconnectd`
restores DBus communication and the GUI repopulates correctly.

**Temporary Workaround:** Disable the "SFTP / Remote Filesystem Integration"
plugin in KDE Connect settings on the PC.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to