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

--- Comment #7 from Oskar <[email protected]> ---
Confirming on Fedora 45 with kwin 6.8.3-1.fc45 (Plasma 6.8.3, Qt 6.11.2,
KF 6.32.0, libinput 1.32.0, kernel 7.3.4-300.fc45, Mesa 26.2.7, AMD Ryzen 5
7430U / Radeon Barcelo iGPU, ASUS Vivobook M3604YA). No drawing tablet, pen
or touchscreen is present.

Crash sequence on one login (systemd-coredump, times EET):

  13:08:34  PID 1544  SIGSEGV        (no KWIN_RESTART_COUNT)
  13:08:36  PID 1651  SIGSEGV        (KWIN_RESTART_COUNT=1)
  13:08:37  PID 1727  started OK     (KWIN_RESTART_COUNT=2, still running)

Identical backtrace in both dumps:

  #4  KWin::InputRedirection::syncTabletWithMouse() const  
libkwin.so.6+0x4a5194
  #5  KWin::PointerInputRedirection::processMotion(...)
  #6  doActivate<false>
  #7  KWin::InputDevice::pointerMotion(...)
  #8  KWin::LibInput::Connection::processEvents()
  #9  KWin::InputRedirection::addInputBackend(...)
  #10 KWin::InputRedirection::setupInputBackends()
  #11 KWin::InputRedirection::InputRedirection(QObject*)
  #12 KWin::InputRedirection::create(QObject*)
  #13 KWin::Application::createInput()
  #14 KWin::ApplicationWayland::performStartup()
  #15 KWin::Application::start()
  #16 main

Input devices here: I2C touchpad "ASUF1202:00 2808:0216 Touchpad" (event8) and
a 2.4 GHz USB receiver mouse "YICHIP 2.4G Receiver Mouse". Nothing tablet-like,
so this is not specific to drawing-tablet hardware.

Disassembly of the stock Fedora build (no debuginfo needed) independently
confirms the null `this` described in comment 6 / attachment 198729:

  KWin::InputRedirection::syncTabletWithMouse() const:
      4a5190: endbr64
      4a5194: movzbl 0x178(%rdi),%eax     <- faulting instruction, rdi = 0
      4a519b: ret

  KWin::PointerInputRedirection::processMotion(...):
      54d332: mov    0x42da9f(%rip),%rax  # &InputRedirection::s_self
      54d339: mov    (%rax),%rbx          # rbx = s_self == nullptr
      54d33f: call   syncTabletWithMouse@plt
      54d344: ...                         # return address in the backtrace

  KWin::InputRedirection::create(QObject*) (operator new + ctor + store):
      4a0238: mov    %rax,(%rdx)          # s_self = <new InputRedirection>

So `this == nullptr` because `s_self` is stored only after the constructor
returns, while the constructor itself calls `setupInputBackends()` ->
`addInputBackend()` -> libinput `processEvents()`, which synchronously emits
`pointerMotion()` for events already queued in libinput. Any pointer motion
pending at that moment reaches `processMotion()` with `s_self` still null.
That also explains the restart loop: the session is restarted while the mouse
is still being moved, so the next start crashes again.

Which events are pending can be arbitrary - a mouse moved right after typing
the password, or input devices being re-enumerated (e.g. USB controller reset
on resume, as reported above). Reproducible on demand here: move the touchpad
while the session is starting, the first kwin instances die with this exact
backtrace.

Two possible fixes: set `s_self` before `setupInputBackends()` is called
(e.g. in `create()` around the constructor), or defer backend setup until
after `create()` has returned. A cheap guard in `processMotion()`
(`if (input()) ...`) would also prevent the null deref, but would silently
drop the pending motion event.

Workaround that works here: leave all pointer devices untouched for a few
seconds after login.

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

Reply via email to