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

            Bug ID: 524916
           Summary: plasma-keyboard busy-loops at ~135% CPU on a closed
                    Wayland connection (EOF/EPIPE never handled)
    Classification: Plasma
           Product: Plasma Keyboard
      Version First unspecified
       Reported In:
          Platform: Fedora RPMs
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

Created attachment 195587
  --> https://bugs.kde.org/attachment.cgi?id=195587&action=edit
file generated by perf utility

DESCRIPTION

plasma-keyboard busy-loops on a socket whose peer has closed (EOF/EPIPE) and
burns ~135% of one CPU, instead of detecting the closed connection and
exiting/reconnecting.

At some point during the session the peer of one of plasma-keyboard's sockets
(fd 81) appears to have closed. plasma-keyboard never handles this: it enters
an endless ppoll/recvmsg/sendmsg cycle on the HUP'ed fd (~3 million syscalls in
15 s), in which recvmsg always returns 0 (EOF), ppoll always returns
POLLIN|POLLHUP, and every sendmsg fails with EPIPE. The QtWaylandClient event
thread (spinning inside wl_display_read_events) and one QSGRenderThread spin at
full speed on this indefinitely. GPU usage stays at 0%, so it is not rendering
load.

Evidence that the burn starts mid-session rather than from launch: `ps -o %cpu`
for the process shows a 22.6% lifetime average while the instantaneous rate is
~135%.

The process also accumulates Qt Quick scenegraph threads: it had 30 threads,
including two QSGRenderThread instances and several Qt Quick/Mesa helper
threads (4x ":gl0", 4x ":gdrv0", 6x ":traceq0"), consistent with a
window/connection having been created and destroyed/recreated without full
cleanup. The older QSGRenderThread (LWP 2091) is parked in
QSGRenderThread::processEventsAndWaitForMore() while the newer one (LWP 820988)
is one of the two spinning threads.

The exact trigger for the peer closing the connection is unknown; the load
appeared some time into the session without an obvious user action (fd 81 is
very likely the compositor/wl_display connection, i.e. possibly KWin
closing/restarting the input-method connection, but I could not confirm which
endpoint it is yet). Once it starts it persists for as long as observed.

Full diagnostics bundle (pk-report.txt) is attached: versions, per-thread
pidstat, strace -c, raw strace excerpt, gdb backtraces of all threads, kwin
supportInformation.

STEPS TO REPRODUCE
1. Log in to a Plasma Wayland session with plasma-keyboard enabled as the
virtual keyboard (default on Fedora).
2. Use the session normally for a while (exact trigger unclear - the load
appeared without an obvious action).
3. Observe plasma-keyboard CPU usage in plasma-systemmonitor/top; once it ramps
up it stays at a constant ~135% (pidstat -u -t) with no interaction with the
on-screen keyboard.

OBSERVED RESULT

plasma-keyboard consumes ~135% of one core continuously (71% in QSGRenderThread
LWP 820988 + 64% in WaylandEventThr LWP 1990; the other 28 threads are idle).
strace shows an endless loop on one fd:

  ppoll([{fd=81, events=POLLIN}], 1, NULL, NULL, 8) = 1 ([{fd=81,
revents=POLLIN|POLLHUP}])
  recvmsg(81, {..., iov_len=2652 ...}, MSG_DONTWAIT|MSG_CMSG_CLOEXEC) = 0      
 <- EOF, peer closed
  sendmsg(81, {..., iov_len=344 ...}, MSG_DONTWAIT|MSG_NOSIGNAL) = -1 EPIPE
(Broken pipe)
  <repeat forever, ~14000 sendmsg/s>

strace -f -c -p <pid> over 15 s (~3M syscalls total):
  45.59%  ppoll   381789 calls
  41.53%  futex   1776823 calls, 195070 errors (EAGAIN)
   5.60%  recvmsg 415205 calls
   3.67%  poll    211335 calls
   3.61%  sendmsg 211335 calls, 211335 errors  <- 100% EPIPE

Per-thread CPU (pidstat -u -t, average):
  plasma-keyboard   134.7% total
    QSGRenderThread  71.0%  (15.8%usr / 55.2%sys)
    WaylandEventThr  63.8%  (14.5%usr / 49.3%sys)

Untested but expected workaround: System Settings -> Keyboard -> Virtual
keyboard: switching to "None" and back to "Plasma Keyboard" restarts the
process and should return CPU to ~0%.

EXPECTED RESULT

When the peer of its Wayland connection closes (EOF / POLLHUP / EPIPE),
plasma-keyboard should tear down and exit (or reconnect) instead of
busy-looping at ~135% CPU.

SOFTWARE/OS VERSIONS
Operating System (available in the Info Center app, or by running `kinfo` in a
terminal window): Fedora Linux 44 (KDE Plasma Desktop Edition), kernel
7.1.9-200.fc44.x86_64
KDE Plasma Version: 6.7.4 (plasma-keyboard 6.7.4-1.fc44, kwin 6.7.4-2.fc44,
plasma-workspace 6.7.4-1.fc44)
KDE Frameworks Version: 6.29.0
Qt Version: 6.11.1 (qtdeclarative 6.11.1-3, qtwayland 6.11.1-1)

ADDITIONAL INFORMATION

Operating System: Fedora Linux 44
KDE Plasma Version: 6.7.4
KDE Frameworks Version: 6.29.0
Qt Version: 6.11.1
Kernel Version: 7.1.9-200.fc44.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen AI 5 340 w/ Radeon 840M
Memory: 24 GiB of RAM (22.8 GiB usable)
Graphics Processor: AMD Radeon 840M Graphics

DISCLAIMER

An LLM model has helped me create the report so I am sorry for any
inaccuracies, but the data in the attached report is real and measured on
device. No slop. I wouldn't want to waste your time. The LLM just generated
description from the report file.

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

Reply via email to