Bug 515835 - All Wayland clients crash with fatal "invalid global wl_output" protocol error when display is hotplugged via KVM switch (atomic modeset failure causes output loss)
Summary: All Wayland clients crash with fatal "invalid global wl_output" protocol erro...
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 6.5.5
Platform: CachyOS Linux
: HI crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-02-10 19:52 UTC by Jason Hagerty
Modified: 2026-02-11 17:30 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Full journalctl output around the crash timestamps will be attached when filing. The logs above are extracted from `journalctl -b 0 (42.08 KB, text/x-log)
2026-02-10 19:52 UTC, Jason Hagerty
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Hagerty 2026-02-10 19:52:16 UTC
Created attachment 189445 [details]
Full journalctl output around the crash timestamps will be attached when filing. The logs above are extracted from `journalctl -b 0

### Overview

When a KVM switch (or suspend/resume) causes a display to disconnect and
reconnect on a different DP-MST connector, the underlying DRM atomic modeset
fails. During this failure, KWin removes the wl_output global and all
connected Wayland clients receive a fatal protocol error:

```
wl_registry#2: error 0: invalid global wl_output (126)
The Wayland connection experienced a fatal error: Protocol error
```

This kills every single application in the session: plasmashell, konsole,
browsers, kdeconnect, krunner, kded6, xdg-desktop-portal-kde, and more.
XWayland also crashes, killing all X11 applications. plasmashell restarts
(because it's managed by the session), but all user state is lost.

### System Information

- KDE Plasma 6.5.5, KWin 6.5.5-3.1
- Qt 6.x, KDE Frameworks (CachyOS packages)
- Kernel: 6.18.9-2-cachyos
- GPU: Intel Iris Plus Graphics 645 (Coffee Lake, i915 driver)
- Machine: MacBookPro15,4
- Monitor: BenQ RD280U (3840x2560, DP-MST, built-in KVM switch)
- Session: Wayland (plasmalogin display manager)

### Steps to Reproduce

1. Run KDE Plasma Wayland session with several applications open
2. Connect to a monitor with a built-in KVM switch via Thunderbolt/DP-MST
3. Switch the KVM to another machine (display disconnects)
4. Switch the KVM back (display reconnects on a different DP connector)
5. Observe: all open applications are killed, plasmashell restarts

### Frequency

Approximately 5 out of 12 KVM switches cause the full client kill.
Happens multiple times daily with normal KVM usage.

### Detailed Failure Sequence

The following is captured from `journalctl -b 0` at 10:07:57 on 2026-02-10:

**1. Atomic modeset fails (kernel i915 issue):**
```
kwin_wayland[1136]: Atomic modeset test failed! Invalid argument
```
(Repeated multiple times over ~10 seconds as the kernel retries.)

**2. KWin loses all outputs:**
```
polkit-kde-authentication-agent-1[23339]: There are no outputs - creating placeholder screen
kactivitymanagerd[23375]: There are no outputs - creating placeholder screen
xdg-desktop-portal-kde[23353]: There are no outputs - creating placeholder screen
kded6[23345]: There are no outputs - creating placeholder screen
konsole[26732]: There are no outputs - creating placeholder screen
plasmashell[23684]: There are no outputs - creating placeholder screen
plasmashell[23684]: requesting unexisting screen available rect -1
```

**3. KWin sends invalid wl_output global to ALL clients:**
```
kwin_wayland_wrapper[1136]: error in client communication (pid 1136)
kwin_wayland_wrapper[23356]: XWAYLAND: wl_registry#2: error 0: invalid global wl_output (126)
kwin_wayland_wrapper[23356]: (EE) failed to dispatch Wayland events: Protocol error
```

**4. Every Wayland client crashes with fatal protocol error:**
```
polkit-kde-authentication-agent-1[23339]: wl_registry#2: error 0: invalid global wl_output (126)
polkit-kde-authentication-agent-1[23339]: The Wayland connection experienced a fatal error: Protocol error
xdg-desktop-portal-kde[23353]: wl_registry#2: error 0: invalid global wl_output (126)
xdg-desktop-portal-kde[23353]: The Wayland connection experienced a fatal error: Protocol error
kactivitymanagerd[23375]: The Wayland connection experienced a fatal error: Protocol error
kded6[23345]: The Wayland connection experienced a fatal error: Protocol error
konsole[26732]: The Wayland connection experienced a fatal error: Protocol error
krunner[26666]: The Wayland connection experienced a fatal error: Protocol error
kwalletd6[27308]: The Wayland connection experienced a fatal error: Protocol error
kdeconnectd[23784]: The Wayland connection experienced a fatal error: Protocol error
baloorunner[26710]: The Wayland connection experienced a fatal error: Protocol error
ksecretd[27347]: The Wayland connection experienced a fatal error: Protocol error
thorium-browser[27265]: wl_registry#2: error 0: invalid global wl_output (126)
```

**5. XWayland crashes, killing all X11 apps:**
```
kwin_wayland[1136]: The X11 connection broke (error 1)
kaccess[23346]: The X11 connection broke (error 1). Did the X11 server die?
xembedsniproxy[23343]: The X11 connection broke (error 1). Did the X11 server die?
gmenudbusmenuproxy[23344]: The X11 connection broke (error 1). Did the X11 server die?
```

**6. plasmashell restarts (new PID), all user state is lost.**

### Analysis

The Wayland protocol error `invalid global wl_output (N)` means that a
client attempted to bind to a wl_output global that no longer exists.
This is a fatal protocol error per the Wayland specification -- clients
cannot recover from it.

The issue appears to be that when atomic modeset fails and the DRM
connector is lost, KWin removes the wl_output global, but the removal and
any subsequent client operations race, resulting in clients referencing
the stale global ID.

Importantly, note that:
- KWin itself (PID 1136) survives -- it is NOT crashing
- The problem is that KWin sends a protocol error to its connected clients
- ALL clients are affected regardless of toolkit (Qt, GTK, XWayland, SDL)
- This same error occurs with two different global IDs (114 and 126) across
  different occurrences, confirming it's the wl_output global being removed

### Expected Behavior

1. When atomic modeset fails, KWin should retry or wait for the display to
   reconnect rather than immediately removing the wl_output global
2. If the output must be removed temporarily, the removal should not cause
   protocol errors for connected clients
3. XWayland should be restarted automatically if it crashes (partially
   addressed by existing work, but it doesn't help when the root cause
   kills all native Wayland clients too)
4. At minimum, plasma-managed services (kded6, krunner, etc.) should be
   resilient to temporary output loss

### Related Bugs

- **Bug 511988**: "Random GUI full freeze when using a KVM switch" --
  same trigger (KVM switch) but different symptom (total freeze vs. protocol
  error killing all clients). May share root cause in output handling.
- **Bug 452435**: "SDL Applications crash with invalid global
  wp_drm_lease_device_v1 when display unplugged" -- same class of bug
  (invalid global during hotplug) but for a different global type. Was fixed
  in 2022 by delaying global destruction. A similar fix may be needed for
  wl_output in this scenario.
- **Bug 485318**: "kwin_wayland crashes in updateOutputs() when displays
  intermittently available after suspend" -- related output management
  crash, fixed in 6.1. Our issue is different (KWin doesn't crash, it
  sends protocol errors).
- **Bug 513040**: "black screen in kwin wayland after disconnecting usb-c
  monitor" -- shows same "Atomic modeset test failed" errors, different
  symptom (black screen vs. client kill).

### Upstream Kernel Bug

The underlying atomic modeset failure is caused by an i915 kernel driver
bug where DP-MST topology state becomes corrupted during KVM-triggered
hotplug. A separate bug report will be filed against drm/i915. However,
KWin should handle modeset failures gracefully without killing all clients
with protocol errors, regardless of the kernel driver behavior.
https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15682

### Logs

(Full journalctl output around the crash timestamps will be attached when
filing. The logs above are extracted from `journalctl -b 0`.)
Comment 1 TraceyC 2026-02-11 17:30:08 UTC
Thank you for the very detailed report and analysis. That's really helpful.

This exact error was last seen in bug 479720, which unfortunately didn't really go anywhere.
The kwin maintainers will take a more detailed look.