Bug 459368

Summary: Crash in Kscreen OSD
Product: [Plasma] plasmashell Reporter: Iyán Méndez Veiga <me>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: kde, me, miranda, noga.dany, pepko94, qydwhotmail
Priority: NOR Keywords: regression, wayland
Version: 5.25.90   
Target Milestone: 1.0   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: systemd log after plasma crashed
backtrace
Backtrace plasmashell
Backtrace kscreen_osd

Description Iyán Méndez Veiga 2022-09-19 07:15:39 UTC
Created attachment 152208 [details]
systemd log after plasma crashed

SUMMARY
With Plasma 5.25 I had zero issues when working with a docking station. With Plasma 5.26 Beta, I had already a few crashes when connecting the laptop to the station. First time, I had to reboot the laptop. Second time I lost the background (and right click would not work), but the rest of applications would still work as normal. Crashes happen in both "directions", when I connect the laptop to the docking station, but also when I disconnect it.

I will be happy to provide any logs that you consider useful to debug this. Please, just ask me what to provide. For now, I'm attaching some logs from systemd.

STEPS TO REPRODUCE
1. Install the beta
2. Connect laptop to a docking station
3. Observe crashes

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.25.90
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20XYCTO1WW
System Version: ThinkPad X1 Yoga Gen 6
Comment 1 Fushan Wen 2022-09-19 07:56:00 UTC
Can you provide backtrace of plasmashell when it crashed? Also from the log kscreen_osd_service also crashed, so the backtrace of kscreen_osd_service is also needed.
Comment 2 Iyán Méndez Veiga 2022-09-19 08:16:03 UTC
I will try to provide those in a bit. How should I exactly do this? I restart the system, attach gdb to the plasmashell process and then connect to the docking station so it crashes? How can I do it for the kscreen_osd_service? It doesn't seem to be running all the times.
Comment 3 Fushan Wen 2022-09-19 08:33:03 UTC
(In reply to Iyán Méndez Veiga from comment #2)
> I will try to provide those in a bit. How should I exactly do this? I
> restart the system, attach gdb to the plasmashell process and then connect
> to the docking station so it crashes? How can I do it for the
> kscreen_osd_service? It doesn't seem to be running all the times.

Have you installed coredumpctl? run `coredumpctl --no-pager` to see the PID of plasmashell/kscreen_osd_service, and run `coredumpctl gdb <PID>` to get the backtrace.
Comment 4 ratijas 2022-09-19 11:11:42 UTC
Maybe this will fix it: https://invent.kde.org/plasma/kscreen/-/merge_requests/132
Comment 5 retired 2022-09-19 18:07:25 UTC
(In reply to ratijas from comment #4)
> Maybe this will fix it:
> https://invent.kde.org/plasma/kscreen/-/merge_requests/132

I am also seeing some instability with 5.25.90.
skcreen_osd_service crashes on exit but it does its job

Tried recompiling with 18171d60 applied, but it still crashes.

Operating System: Arch Linux
KDE Plasma Version: 5.25.90
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 5.19.9-zen1-1-zen (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 4800H with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD RENOIR
Manufacturer: LENOVO
Product Name: 82B1
System Version: Lenovo Legion 5 15ARH05H

Will try to get trace and come back.
Comment 6 retired 2022-09-19 18:28:51 UTC
Created attachment 152233 [details]
backtrace

Attaching backtrace, hope it has something useful in it.
Comment 7 Iyán Méndez Veiga 2022-09-20 12:39:26 UTC
Created attachment 152256 [details]
Backtrace plasmashell
Comment 8 Iyán Méndez Veiga 2022-09-20 12:45:56 UTC
Created attachment 152257 [details]
Backtrace kscreen_osd
Comment 9 Fushan Wen 2022-09-21 03:14:30 UTC
pasting inline:

                #0  0x00007f6d8cc93368 pthread_sigmask (libc.so.6 + 0x93368)
                #1  0x00007f6d8cc3eadd sigprocmask (libc.so.6 + 0x3eadd)
                #2  0x00007f6d8f6321cb _ZN6KCrash15setCrashHandlerEPFviE (libKF5Crash.so.5 + 0x51cb)
                #3  0x00007f6d8f634837 _ZN6KCrash19defaultCrashHandlerEi (libKF5Crash.so.5 + 0x7837)
                #4  0x00007f6d8cc3e8e0 n/a (libc.so.6 + 0x3e8e0)
                #5  0x00007f6d8b5b09bb _ZN15QtWaylandClient19QWaylandInputDevice5Touch11touch_frameEv (libQt5WaylandClient.so.5 + 0x759bb)
                #6  0x00007f6d8e114536 n/a (libffi.so.8 + 0x7536)
                #7  0x00007f6d8e111037 n/a (libffi.so.8 + 0x4037)
                #8  0x00007f6d8f8b15e2 n/a (libwayland-client.so.0 + 0x75e2)
                #9  0x00007f6d8f8b1d73 n/a (libwayland-client.so.0 + 0x7d73)
                #10 0x00007f6d8f8b1f8c wl_display_dispatch_queue_pending (libwayland-client.so.0 + 0x7f8c)
                #11 0x00007f6d8b5acc56 _ZN15QtWaylandClient15QWaylandDisplay13flushRequestsEv (libQt5WaylandClient.so.5 + 0x71c56)
                #12 0x00007f6d8d6b0830 _ZN7QObject5eventEP6QEvent (libQt5Core.so.5 + 0x2b0830)
                #13 0x00007f6d8e378abc _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent (libQt5Widgets.so.5 + 0x178abc)
                #14 0x00007f6d8d68cf38 _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent (libQt5Core.so.5 + 0x28cf38)
                #15 0x00007f6d8d68da33 _ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData (libQt5Core.so.5 + 0x28da33)
                #16 0x00007f6d8d6d3818 n/a (libQt5Core.so.5 + 0x2d3818)
                #17 0x00007f6d8bc6fc6b g_main_context_dispatch (libglib-2.0.so.0 + 0x54c6b)
                #18 0x00007f6d8bcc6001 n/a (libglib-2.0.so.0 + 0xab001)
                #19 0x00007f6d8bc6d392 g_main_context_iteration (libglib-2.0.so.0 + 0x52392)
                #20 0x00007f6d8d6d764c _ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE (libQt5Core.so.5 + 0x2d764c)
                #21 0x00007f6d8d6856ec _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE (libQt5Core.so.5 + 0x2856ec)
                #22 0x00007f6d8d6901e9 _ZN16QCoreApplication4execEv (libQt5Core.so.5 + 0x2901e9)
                #23 0x000055f9661bf0e5 n/a (plasmashell + 0x230e5)
                #24 0x00007f6d8cc29290 n/a (libc.so.6 + 0x29290)
                #25 0x00007f6d8cc2934a __libc_start_main (libc.so.6 + 0x2934a)
                #26 0x000055f9661bf495 n/a (plasmashell + 0x23495)
Comment 10 Fushan Wen 2022-09-21 06:13:03 UTC
#0  0x00007efcb01d36cf in QWindow::setVisible (this=<optimized out>, visible=false)
    at kernel/qwindow.cpp:623
#1  0x00007efcafe2d361 in QtPrivate::QSlotObjectBase::call (a=<optimized out>,
    r=<optimized out>, this=<optimized out>, this=<optimized out>, r=<optimized out>,
    a=<optimized out>)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#2  doActivate<false> (sender=0x55ee43790740, signal_index=0, argv=0x7ffe2cf8f440)
    at kernel/qobject.cpp:3919
#3  0x00007efcafe2d704 in QObject::destroyed (this=<optimized out>, _t1=<optimized out>)
    at .moc/moc_qobject.cpp:219
#4  0x00007efcafe23ccc in QObject::~QObject (this=<optimized out>, this=<optimized out>)
    at kernel/qobject.cpp:1010
#5  0x00007efcb10ef72a in KScreen::Output::~Output (this=<optimized out>,
    this=<optimized out>) at /usr/src/debug/libkscreen-5.25.90/src/output.cpp:176
#6  QtSharedPointer::CustomDeleter<KScreen::Output, QtSharedPointer::NormalDeleter>::execute
    (this=<optimized out>) at /usr/include/qt/QtCore/qsharedpointer_impl.h:187
#7  QtSharedPointer::ExternalRefCountWithCustomDeleter<KScreen::Output, QtSharedPointer::NormalDeleter>::deleter (self=<optimized out>)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:205
#8  0x000055ee422087a5 in QtSharedPointer::ExternalRefCountData::destroy (
    this=0x55ee4378de40) at /usr/include/qt/QtCore/qsharedpointer_impl.h:149
#9  QSharedPointer<KScreen::Config>::deref (dd=0x55ee4378de40)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:458
#10 QSharedPointer<KScreen::Output>::deref (dd=<optimized out>, dd=<optimized out>)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:454
#11 QSharedPointer<KScreen::Output>::deref (this=<optimized out>, this=<optimized out>)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:453
#12 QSharedPointer<KScreen::Output>::~QSharedPointer (this=<optimized out>,
Comment 11 Vlad Zahorodnii 2022-09-21 07:05:11 UTC
At quick glance, it looks like kscreen osd crashes in

osd/osd.cpp
35:    connect(output.data(), &KScreen::Output::destroyed, this, &Osd::hideOsd);

i.e.

    if (m_osdActionSelector) {
        m_osdActionSelector->setVisible(false);
    }
Comment 12 David Edmundson 2022-09-21 09:30:26 UTC
WIP at https://invent.kde.org/plasma/kscreen/-/merge_requests/132
Comment 13 retired 2022-09-21 17:08:55 UTC
(In reply to David Edmundson from comment #12)
> WIP at https://invent.kde.org/plasma/kscreen/-/merge_requests/132

I tried to recompile with this patch, turns out Arch Linux changed some defaults in how it handles extracted sources since I last played with makepkg. User error, disregard comment 5.

Anyways, patched for sure this time:


Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fcc2c3666cf in QWindow::setVisible (this=<optimized out>, visible=false) at kernel/qwindow.cpp:623
Downloading 0.08 MB source file /usr/src/debug/qtbase/src/gui/kernel/qwindow.cpp
623         d->setVisible(visible);                                                         
[Current thread is 1 (Thread 0x7fcc27a0a840 (LWP 3795))]
(gdb) bt
#0  0x00007fcc2c3666cf in QWindow::setVisible (this=<optimized out>, visible=false)
    at kernel/qwindow.cpp:623
#1  0x00007fcc2bfc0381 in QtPrivate::QSlotObjectBase::call (a=<optimized out>, 
    r=<optimized out>, this=<optimized out>, this=<optimized out>, r=<optimized out>, 
    a=<optimized out>)
    at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#2  doActivate<false> (sender=0x55fad97e8a20, signal_index=0, argv=0x7fffb50a0a20)
    at kernel/qobject.cpp:3919
#3  0x00007fcc2bfc0724 in QObject::destroyed (this=<optimized out>, _t1=<optimized out>)
    at .moc/moc_qobject.cpp:219
#4  0x00007fcc2bfb6cec in QObject::~QObject (this=<optimized out>, this=<optimized out>)
    at kernel/qobject.cpp:1010
#5  0x00007fcc2d28272a in KScreen::Output::~Output (this=<optimized out>, 
    this=<optimized out>) at /usr/src/debug/libkscreen-5.25.90/src/output.cpp:176
#6  QtSharedPointer::CustomDeleter<KScreen::Output, QtSharedPointer::NormalDeleter>::execute
    (this=<optimized out>) at /usr/include/qt/QtCore/qsharedpointer_impl.h:187
#7  QtSharedPointer::ExternalRefCountWithCustomDeleter<KScreen::Output, QtSharedPointer::NormalDeleter>::deleter (self=<optimized out>)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:205
#8  0x000055fad8aadb59 in QtSharedPointer::ExternalRefCountData::destroy (
    this=0x55fad98141a0) at /usr/include/qt/QtCore/qsharedpointer_impl.h:149
#9  QSharedPointer<KScreen::Output>::deref (dd=0x55fad98141a0)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:458
#10 QSharedPointer<KScreen::Output>::deref (dd=0x55fad98141a0)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:454
#11 QSharedPointer<KScreen::Output>::deref (this=0x55fad9882460)
    at /usr/include/qt/QtCore/qsharedpointer_impl.h:453
#12 QSharedPointer<KScreen::Output>::~QSharedPointer (this=0x55fad9882460,
Comment 14 Iyán Méndez Veiga 2022-09-27 15:22:13 UTC
This issue can be "minimized" if I turn off the laptop, plugged it to the docking station and turn it on already attached. And it is "maximized" with hot plugging. I also noticed that if the laptop is suspended and I attach it to the docking station, it is not "aware" that the lid is off and the screen remains on, while with Plasma 5.25, laptop would resume with the screen off and only show in the external one(s).
Comment 15 ratijas 2022-10-13 12:38:18 UTC
Git commit 6ba043519e9834202fc062cbaf1a41f76f521730 by ivan tkachenko.
Committed on 12/10/2022 at 15:20.
Pushed by ratijas into branch 'master'.

osd: Fix a crash when quitting from QML signal handler

kscreen_osd_service[9979]:
    Object 0x55a9840ff5c0 destroyed while one of its QML signal handlers is in progress.
    Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop.
    This behavior is NOT supported!
    qrc:/qml/OsdSelector.qml:102: function() { [native code] }

Call to quit() should be posted to an event loop to avoid destroying Osd
objects with their engines while a key press signal handler is still
running. Additional clean up must be performed to ensure that a map
does not contain dangling references, ans thus double call to hideOsd()
won't cause another crash either.

Also, don't bother hiding individual OSD instances if we are about to
quit anyway. That's what other code path with timer is [not] doing
already.

M  +5    -5    osd/osdmanager.cpp

https://invent.kde.org/plasma/kscreen/commit/6ba043519e9834202fc062cbaf1a41f76f521730
Comment 16 ratijas 2022-10-13 12:43:52 UTC
Git commit a917bf19436c0e86eb993fe89a0f1df536b8fdc6 by ivan tkachenko.
Committed on 13/10/2022 at 12:43.
Pushed by ratijas into branch 'Plasma/5.26'.

osd: Fix a crash when quitting from QML signal handler

kscreen_osd_service[9979]:
    Object 0x55a9840ff5c0 destroyed while one of its QML signal handlers is in progress.
    Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop.
    This behavior is NOT supported!
    qrc:/qml/OsdSelector.qml:102: function() { [native code] }

Call to quit() should be posted to an event loop to avoid destroying Osd
objects with their engines while a key press signal handler is still
running. Additional clean up must be performed to ensure that a map
does not contain dangling references, ans thus double call to hideOsd()
won't cause another crash either.

Also, don't bother hiding individual OSD instances if we are about to
quit anyway. That's what other code path with timer is [not] doing
already.
(cherry picked from commit 6ba043519e9834202fc062cbaf1a41f76f521730)

M  +5    -5    osd/osdmanager.cpp

https://invent.kde.org/plasma/kscreen/commit/a917bf19436c0e86eb993fe89a0f1df536b8fdc6
Comment 17 ratijas 2022-10-13 12:48:50 UTC
IIUC this issue is not only about KScreen OSD service, so it can't be closed as completed/fixed just yet.
Comment 18 David Edmundson 2022-10-13 12:54:38 UTC
We've got a few reports about several things at once in here. 

Lets make this about the OSD crashing which is 2 of the backtraces and mark it as closed. Remaining issues can exist as new bug reports.