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

            Bug ID: 528527
           Summary: plasmashell segfaults in QMenuProxy::openRelative()
                    when the menu's visualParent has no QWindow
    Classification: Plasma
           Product: plasmashell
      Version First 6.8.2
       Reported In:
          Platform: CachyOS
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: generic-crash
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: 1.0

Created attachment 198215
  --> https://bugs.kde.org/attachment.cgi?id=198215&action=edit
Report in .md format

plasmashell segfaults in QMenuProxy::openRelative() when the menu's
visualParent has no QWindow

    Status: open; one occurrence captured with a full core (2026-11-08 10:28:42
WET). Not yet filed upstream.
    Component: libplasma 6.8.2-1.1 —
src/declarativeimports/plasmaextracomponents/qmenu.cpp (packaged into
/usr/lib/qt6/qml/org/kde/plasma/extras/libplasmaextracomponentsplugin.so). In
KDE Bugzilla this is product libplasma, component components.
    Trigger site: plasma-desktop 6.8.2 — Task Manager applet, ContextMenu.qml →
openRelative().
    Host / kernel: cachydon, 7.3.1-8-cachydon (built kernel; CachyOS
userspace).
    Impact: plasmashell dies with SIGSEGV and is restarted by systemd. All
panels, widgets and the context menu are torn down and recreated (≈14 s
outage). No data loss; desktop state (open menus, widget popups) is lost.
    Owner: upstream (libplasma). Local workaround only.

Environment

Plasma  6.8.2 (plasmashell, kwin_wayland)
libplasma       6.8.2-1.1
plasma-desktop  6.8.2-1.1
Qt      6.12.0 (libQt6Gui.so.6.12.0, libQt6Qml.so.6)
Session         Wayland (XDG_SESSION_TYPE=wayland, XDG_CURRENT_DESKTOP=KDE)
GPU     AMD Radeon 610M iGPU (amdgpu, PCI 13:00.0); Intel Arc B580 present but
not driving this output
Outputs         one connected: card0-DP-2, 3440×1440; DP-1, DP-3, HDMI-A-1
disconnected
VT      tty2 login at 10:28; fbcon: Taking over console at 10:28:09
Distro  CachyOS (Arch-based), packages 6.8.2-1.1 = CachyOS rebuilds of Arch's
6.8.2
Summary

QMenuProxy::openRelative() computes a popup's screen-boundary correction with:

if (auto window = parentItem->window(); //
    QScreen *screen = window->screen()) {

parentItem->window() is allowed to return nullptr for an item that is not
attached to a QQuickWindow. The code checks the result of window->screen() but
never checks window itself, so a null window dereferences address 0x8 inside
QWindow::screen().
Steps to reproduce

Not yet deliberately reproduced; the sequence below is what the captured logs
show. Suspected repro:

    Wayland Plasma 6.8.2, single DisplayPort output on amdgpu, Task Manager
widget on a panel.
    Invoke the Task Manager context menu (ContextMenu.qml::show() →
openRelative()), or have a context-menu show() pending.
    Cause a display-geometry change while the menu is being positioned: switch
VT (Ctrl+Alt+F2 … back) or unplug/replug the DP cable.
    plasmashell segfaults in QMenuProxy::openRelative().

Observed timeline (single occurrence):

10:28:09  kernel: fbcon: Taking over console                 ← VT switch
10:28:12  amdgpu: LTTPR count is nonzero ... (DP re-detect)
10:28:20  plasmashell[1174]: requesting unexisting screen geometry 0
10:28:42  kernel: plasmashell[1174]: segfault at 8 ip ... error 4 in
libQt6Gui.so.6.12.0
10:28:56  systemd[712]: plasma-plasmashell.service: Main process exited,
code=dumped, status=11/SEGV
10:28:56  systemd[712]: Scheduled restart job, restart counter is at 1

requesting unexisting screen geometry is emitted by plasmashell itself when a
containment or item asks for a screen index that is no longer in the screen
list — i.e. the shell knew the screen set was momentarily invalid.

Concurrent but unrelated load: a kernel build (make -j10 ThinLTO link + pahole
-J -j10) was running, peaking at ~15 GB RSS. That caused memory/IO pressure but
is not part of the crash path; the null QWindow is sufficient on its own.
Observed — crash detail

coredumpctl info 1174:

Signal: 11 (SEGV)  si_code: SEGV_MAPERR  Timestamp: 2026-11-08 10:28:42
Command Line: /usr/bin/plasmashell --no-respawn
Size on Disk: 28.4M

Faulting instruction and registers (gdb, core loaded):

#0  QWindow::screen() const
    0x...fdb0 <QWindow::screen()+16>:  mov 0x8(%rdi),%rax
    rip = ...fdb0   rdi = 0x0   rax = 0x0
    si_code = SEGV_MAPERR, faulting address = 0x8

Caller disassembly, libplasmaextracomponentsplugin.so at
QMenuProxy::openRelative()'s boundaryCorrection lambda (+0xa190):

a1a6: mov  0x18(%rdi),%rdi        ; parentItem (visualParent)
a1af: call QQuickItem::window()
a1b5: mov  %rax,%rdi              ; rdi = window  ← may be NULL
a1b8: call QWindow::screen()      ; ← SEGV here, window == nullptr
a1be: test %rax,%rax              ; only the *screen* result is checked

Symbolized stack:

#0  QWindow::screen() const                                      
libQt6Gui.so.6
#1  QMenuProxy::openRelative()::{lambda(int,int)#1}::operator()  
libplasmaextracomponentsplugin.so +0xa1be
#2  QMenuProxy::qt_static_metacall                               
libplasmaextracomponentsplugin.so +0x1023a
#3  QMenuProxy::qt_metacall                                      
libplasmaextracomponentsplugin.so +0x173af
#4  (QML engine)                                                 
libQt6Qml.so.6
#5  (QML engine)                                                 
libQt6Qml.so.6
#6  QV4::QObjectMethod::callInternalWithMetaTypes(...)           
libQt6Qml.so.6
#7  (QML engine)                                                 
libQt6Qml.so.6
#8  QmlCacheGeneratedCode…ContextMenu.qml…aotBuiltFunctions      
org.kde.plasma.taskmanager.so +0x35e4b
#9–#24 QML/QV4 evaluation of a bound signal handler              
libQt6Qml.so.6

Frame #8 is the AOT-compiled ContextMenu.qml of the Task Manager applet; the
QML function that reaches openRelative() is show().
Root cause

Source (v6.8.2, lines 361–402):
https://invent.kde.org/plasma/libplasma/-/blob/v6.8.2/src/declarativeimports/plasmaextracomponents/qmenu.cpp#L381

void QMenuProxy::openRelative()          // line 361
{
    ...
    auto boundaryCorrection = [this, &posLocal, &posGlobal, parentItem](int
hDelta, int vDelta) {
        if (auto window = parentItem->window();          // L381 — may be
nullptr
            QScreen *screen = window->screen()) {        // L382 — deref before
any check
            ...
        } else {
            posGlobal = posLocal.toPoint();              // L402 — only reached
if screen == null
        }
    };

Because the null test for window does not exist, the else branch cannot cover
the window == nullptr case: window->screen() is evaluated as part of the if
condition and crashes before the branch is chosen.

Still present on master (checked 2026-11-08):
https://invent.kde.org/plasma/libplasma/-/blob/master/src/declarativeimports/plasmaextracomponents/qmenu.cpp#L381

Caller in plasma-desktop (v6.8.2):
https://invent.kde.org/plasma/plasma-desktop/-/blob/v6.8.2/applets/taskmanager/qml/ContextMenu.qml#L74

function show(): void {          // ContextMenu.qml
    Plasmoid.contextualActionsAboutToShow();
   
loadDynamicLaunchActions(get(TaskManager.AbstractTasksModel.LauncherUrlWithoutIcon));
    openRelative();              // L74 → QMenuProxy::openRelative()
}

Frame #8's symbol (...ContextMenu.qml...) is this file, compiled into the
applet binary.
Proposed fix

Guard window before calling screen(); keep the existing fallback for both
nulls:

--- a/src/declarativeimports/plasmaextracomponents/qmenu.cpp
+++ b/src/declarativeimports/plasmaextracomponents/qmenu.cpp
@@
-    auto boundaryCorrection = [this, &posLocal, &posGlobal, parentItem](int
hDelta, int vDelta) {
-        if (auto window = parentItem->window(); //
-            QScreen *screen = window->screen()) {
+    auto boundaryCorrection = [this, &posLocal, &posGlobal, parentItem](int
hDelta, int vDelta) {
+        QWindow *window = parentItem->window();
+        QScreen *screen = window ? window->screen() : nullptr;
+        if (screen) {
             QRect geo = screen->geometry();

Alternative without introducing the intermediate screen variable:

if (auto window = parentItem->window()) {
    if (QScreen *screen = window->screen()) {
        ... existing body ...
        posGlobal = pos;
    } else {
        posGlobal = posLocal.toPoint();
    }
} else {
    posGlobal = posLocal.toPoint();
}

QMenuProxy::open() (line 336) already does the right thing: it routes through
mapToGlobalUsingRenderWindowOfItem() (line 320), which checks
parentItem->window() at line 323 before use. openRelative()'s lambda is the odd
one out.
Workaround

None specific to the menu. Mitigations:

    Avoid changing display configuration (VT switch, DP unplug/replug, Meta+P)
while a Task Manager context menu is opening. That is the only known trigger.
    If it happens, plasmashell is restarted automatically by
plasma-plasmashell.service; nothing needs to be done manually.
    Do not bother changing the Global Theme / Look-and-Feel: the crash is in
stock libplasma code reachable from the stock Task Manager, independent of
theme or widget style. (This was initially misattributed to the installed
Andromeda theme; the core disproved that.)

Artifacts / re-capture

Core is retained by systemd; re-extract with:

coredumpctl info 1174                      # summary + stack
coredumpctl dump 1174 -o /tmp/plasmashell.core
gdb -batch -ex "set pagination off" -ex "bt 25" /usr/bin/plasmashell
/tmp/plasmashell.core

Notes for anyone re-symbolizing:

    The binaries still carry .symtab; gdb resolved QMenuProxy::openRelative()
and qt_metacall without external debug info.
    debuginfod.archlinux.org has no debuginfo for this build-id (404).
debuginfod.cachyos.org does (HTTP 200, 3.5 MB for build-id
b48822a12f8d61ef14bb0a4014f248e1de80a25b), but a gdb fetch stalled and was
abandoned; a manual curl to
https://debuginfod.cachyos.org/buildid/b48822a12f8d61ef14bb0a4014f248e1de80a25b/debuginfo
works.

Build IDs at time of crash:
File    Build ID
libplasmaextracomponentsplugin.so      
b48822a12f8d61ef14bb0a4014f248e1de80a25b
org.kde.plasma.taskmanager.so   37fb764c2d466d1bb99bcfbbb853970cac221738
/usr/bin/plasmashell    4d87b31146d9b47220a83b587d169271f8331ff2
Filing notes

    Product / component: libplasma / components
(https://bugs.kde.org/enter_bug.cgi?product=libplasma&component=components)
    Version: 6.8.2 · Platform: Arch Linux (CachyOS) · Severity: crash
    Suggested keywords: wayland, multiscreen
    No duplicate found when searching KDE Bugzilla (REST) for QMenuProxy and
openRelative on 2026-11-08.
    Suggested summary: plasmashell crashes in QMenuProxy::openRelative() when
the menu's visualParent has no QWindow
    Attach: the coredumpctl info output and the symbolized backtrace above.
Keep the description short and point at qmenu.cpp:381.

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

Reply via email to