https://bugs.kde.org/show_bug.cgi?id=528438
Bug ID: 528438
Summary: kscreenlocker_greet crashes on resume when an output
is removed during sleep (frameSwapped lambda uses this
as context)
Classification: Plasma
Product: plasmashell
Version First 6.8.2
Reported In:
Platform: Fedora RPMs
OS: Linux
Status: REPORTED
Severity: crash
Priority: NOR
Component: Screen locking
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: 1.0
kscreenlocker_greet crashes on resume when an output was removed while the
machine was asleep. Seen on 6.8.2 (Fedora 44, kscreenlocker-6.8.2-1.fc44) and
6.7.5, Qt 6.11.2, KWin Wayland. The code is unchanged on master (8d892e91,
greeter/greeterapp.cpp line 420).
STEPS TO REPRODUCE
1. Dock a laptop with an external monitor (here a ThinkPad T480 on an Ultra
Dock).
2. Suspend with "systemctl suspend". The greeter starts about 0.8 s before the
kernel enters suspend.
3. Undock while the machine is asleep, then wake it.
OBSERVED RESULT
The greeter dies with SIGSEGV within 40 ms of the output going away. KWin
starts a new greeter, which can unlock, but it shows a broken screen without
text or video (I have a looping video as background). It happened on 3 of 3
attempts with a custom lock screen shell. One attempt with stock Breeze did not
crash (see below). No core is written because the greeter is non-dumpable.
16:50:07.939 powerdevil: DDCA_EVENT_DISPLAY_DISCONNECTED, card1-DP-3
16:50:07.974 kernel: traps: kscreenlocker_g[16806] general protection fault
ip:7f287d179174 error:0 in libQt6Quick.so.6.11.2[179174,7f287d000000+4eb000]
eu-addr2line resolves offset 0x179174 to QQuickView::rootObject() const. On
6.7.5 the same test faulted in PlasmaQuick::SharedQmlEngine::rootObject() const
(libplasma offset 0x36fe1), with fault addresses 0xb95 and 0xd25.
EXPECTED RESULT
The lock screen stays on the same lockscreen screen after resume and unlocks
normally; the greeter does not crash or get replaced.
CAUSE
greeter/greeterapp.cpp, UnlockApp::createViewForScreen():
auto onFrameSwapped = [this, view] {
markViewsAsVisible(view->rootObject());
};
connect(view, &QQuickWindow::frameSwapped, this, onFrameSwapped,
static_cast<Qt::ConnectionType>(Qt::QueuedConnection |
Qt::SingleShotConnection));
The context object is "this", so the queued call outlives the view.
handleScreen() deletes the view on screenRemoved. If the view swaps its first
frame and is deleted before the queued call runs, view->rootObject() is called
on freed memory.
After suspend both conditions hold. Measured with WAYLAND_DEBUG=client
kscreenlocker_greet --testing, the time to the first buffer attach was 1035,
1350 and 1309 ms for Breeze and 882, 908 and 919 ms for the custom shell. Both
are longer than the 0.8 s between greeter start and suspend, so the first frame
is still pending at resume and swaps around the moment the output is removed.
FIX
Pass the view as the context object, so Qt drops the pending call when the view
is deleted:
- connect(view, &QQuickWindow::frameSwapped, this, onFrameSwapped,
static_cast<Qt::ConnectionType>(Qt::QueuedConnection |
Qt::SingleShotConnection));
+ connect(view, &QQuickWindow::frameSwapped, view, onFrameSwapped,
static_cast<Qt::ConnectionType>(Qt::QueuedConnection |
Qt::SingleShotConnection));
The lambda only touches view and this, and this outlives every view. Built
locally as 6.8.2-1.fc44 plus this one-line change: 2 of 2 undock-while-asleep
resumes with the same custom shell passed (external output DP-4, then DP-3).
The greeter that started before suspend kept running and unlocked the session,
with no trap in the kernel log and no replacement greeter. A merge request with
the change follows.
--
You are receiving this mail because:
You are watching all bug changes.