Bug 466914

Summary: Kded5 crash when switchin between monitor and tv
Product: [Plasma] KScreen Reporter: Bucior <bucior3663>
Component: OSD and Plasma appletAssignee: kscreen-bugs-null <kscreen-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: luca.bacci, nate
Priority: NOR    
Version: 5.27.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.27.4
Sentry Crash Report:
Attachments: kded5 crash
kscreen crash

Description Bucior 2023-03-05 20:59:22 UTC
Created attachment 157024 [details]
kded5 crash

I have one monitor connected via DP and tv connected via HDMI, only one is used at the same time, when i switch to tv as main display and then try to switch back to monitor osd (super + p) is not working


Operating System: Arch Linux 
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.2.2-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: AMD Radeon RX 6800 XT
Manufacturer: Gigabyte Technology Co., Ltd.
Product Name: X570S AORUS ELITE AX
System Version: -CF
Comment 1 Nate Graham 2023-03-08 04:54:12 UTC
I genuinely cannot tell which KDED module is crashing based on the backtrace. I see a lot of glib and GObject function calls though... Luca, do you think it could be the GTK settings daemon?
Comment 2 Luca Bacci 2023-03-08 12:58:59 UTC
Yeah, may be. I'm gonna take a look at this!
Comment 3 Luca Bacci 2023-03-08 15:38:01 UTC
This seems to be an issue in the dconf GSettingsBackend. I have opened an issue at https://gitlab.gnome.org/GNOME/dconf/-/issues/79 for now, but will investigate more!
Comment 4 Bucior 2023-03-09 17:46:16 UTC
Created attachment 157154 [details]
kscreen crash

I also had this crash, just switching monitors, previous i was using tv more i will try to reproduce once more
Comment 5 Bug Janitor Service 2023-03-24 03:45:37 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Luca Bacci 2023-03-24 13:20:47 UTC
Thanks for the report, Bucior!

Seems to be a different issue according to the stacktrace, most probably in KScreen. The stacktrace is very useful! :)

KScreen::Osd keeps a reference to a LibKScreen::Output. When Osd instances are destroyed, their references to LibKScreen::Output instances are dropped, and that can cause their immediate destruction.

Osd also subscribes as an observeer for its member LibKScreen::Output's destruction: https://invent.kde.org/plasma/kscreen/-/blob/v5.27.2/osd/osd.cpp#L33. The handler method is Osd::hideOsd() is executed, but at that time Osd is already in the process of being destructed...

As for fixes, we may ::disconnect() in Osd's destructor. However I don't get why Osd observes its member object for destruction if it keeps a reference to it?
Comment 7 Luca Bacci 2023-03-24 13:37:17 UTC
Observing the member output object for destruction was done as part of https://invent.kde.org/plasma/kscreen/-/commit/071282f545, which sends to https://phabricator.kde.org/D9414
Comment 8 Bug Janitor Service 2023-03-24 13:54:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/199
Comment 9 Luca Bacci 2023-03-27 21:12:14 UTC
Git commit 8f5fc740065e38dd37cbd966a5abebfaeccaa495 by Luca Bacci.
Committed on 26/03/2023 at 10:18.
Pushed by davidedmundson into branch 'master'.

OSD: Do not connect to member QObject's destroyed signal

We're keeping a strong reference to it

M  +0    -1    osd/osd.cpp

https://invent.kde.org/plasma/kscreen/commit/8f5fc740065e38dd37cbd966a5abebfaeccaa495
Comment 10 Nate Graham 2023-03-28 14:41:00 UTC
Git commit 7a5e79edf6d12e1da6377a277a905d47424d688c by Nate Graham, on behalf of Luca Bacci.
Committed on 28/03/2023 at 14:40.
Pushed by ngraham into branch 'Plasma/5.27'.

OSD: Do not connect to member QObject's destroyed signal

We're keeping a strong reference to it


(cherry picked from commit 8f5fc740065e38dd37cbd966a5abebfaeccaa495)

M  +0    -1    osd/osd.cpp

https://invent.kde.org/plasma/kscreen/commit/7a5e79edf6d12e1da6377a277a905d47424d688c