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

Jérémy L <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #33 from Jérémy L <[email protected]> ---
I was able to reproduce this consistently and capture the exact call stack with
gdb. The root cause is a different code path than the Docker /tmp/runc-*
hypothesis mentioned in earlier comments.

## Versions

- Dolphin 23.08.5
- KF5 5.115.0 (libkf5solid5 5.115.0-0ubuntu5)
- Plasma 5.27.12
- Ubuntu 24.04.4 LTS, kernel 6.8.0-110

## Reproduction (instant with active Docker)

1. Have ~20 running Docker containers (overlay storage driver), especially with
healthchecks running `docker exec`
2. Open Dolphin, Ctrl+L, type any path
3. Location bar wipes back to the current URL within hundreds of ms

## Root cause (gdb stack trace, captured 549 times during ~10s of typing)

```
#0  KUrlComboBox::setUrl(QUrl const&)              from libKF5KIOWidgets.so.5
#1  ?? in libKF5KIOFileWidgets.so.5
#2  Qt5Core signal dispatch
#3  QAbstractItemModel::dataChanged(...)            from libQt5Core.so.5
#4-6 ?? in libKF5KIOFileWidgets.so.5 (KFilePlacesModel)
#7  Qt5Core signal dispatch
#8  Solid::StorageAccess::accessibilityChanged(bool, QString const&)  from
libKF5Solid.so.5
#9-14 ?? in libKF5Solid.so.5 / libQt5Core.so.5
#15-16 Qt5Core
#17 QSocketNotifier::activated(...)                 from libQt5Core.so.5
#18 QSocketNotifier::event(QEvent*)                 from libQt5Core.so.5
```

## Chain of events

1. Docker creates/removes overlay mounts in /proc/mounts (containerd,
healthchecks, `docker exec`...)
2. The Solid Fstab backend's FstabWatcher uses a QSocketNotifier on
/proc/mounts and wakes up on every change
3. It re-emits Solid::StorageAccess::accessibilityChanged for fstab/network
devices (e.g. NFS mounts present in fstab)
4. KFilePlacesModel (sidebar Places model) emits
QAbstractItemModel::dataChanged
5. KUrlNavigator's slot reacts by calling KUrlComboBox::setUrl(currentUrl),
**unconditionally overwriting the line edit content even while the user is
editing it**

## Why earlier "fix by stopping Docker" worked but the cause is broader

Stopping Docker eliminates the /proc/mounts changes → no more wake-ups → no
more cascade. This is what the comments in this bug describe. But the root
issue isn't Docker — it's that any frequent mount/unmount activity (Docker,
fuse, network shares, any process spamming /proc/mounts) triggers the cascade.
The fix should not require stopping Docker.

## Proposed fix

KUrlNavigator (or KUrlComboBox::setUrl itself) should bail out when the user is
actively editing the location bar. A simple heuristic that works reliably:

```cpp
void KUrlComboBox::setUrl(const QUrl &url) {
    auto *fw = QApplication::focusWidget();
    if (fw && (fw == this || fw == lineEdit())) {
        // User is editing — don't overwrite their input.
        // Update internal state only, defer text update until focus is lost.
        return;
    }
    // ... existing implementation
}
```

(focus may be on the combo itself due to focus proxy, hence the two checks)

## Workaround for affected users (until upstream fix)

I built a small LD_PRELOAD shim that intercepts KUrlComboBox::setUrl and
applies the focus check above. ~50 lines of C++, no Qt dev headers needed
(everything via dlsym). Tested for several hours on the above setup —
completely eliminates the symptom, no observable side-effects.

Happy to provide the shim code if useful.

## Related observation

The same dataChanged cascade can be triggered without Docker, e.g. by mount
events on FUSE filesystems or by any process touching /proc/mounts rapidly. So
the workaround "stop Docker" is misleading — the bug exists for any user with a
busy mount table.

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

Reply via email to