Bug 492213

Summary: kwin_wayland occasionally crashes in KWin::XdgSurfaceWindow::frameRectToBufferRect() while using the Krohnkite tiler
Product: [Plasma] kwin Reporter: Antti Savolainen <antti.savo>
Component: generic-crashAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: nate
Priority: NOR    
Version: 6.1.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 6.2.0
Sentry Crash Report:
Attachments: bt full

Description Antti Savolainen 2024-08-26 14:05:45 UTC
Created attachment 172971 [details]
bt full

SUMMARY
Demonstrative video: https://youtu.be/8pXNSHwRr98?t=130
kwin_wayland sometimes crashes with the Krohnkite tiler in normal use. I was not able to create specific circumstances when it happens but it happens when you have multiple windows open and the tiler is adjusting the window locations. I was able to create a semi-reproducible environment with kde-builder tests.

STEPS TO REPRODUCE
1. Use the Krohnkite Kwin script 
2. Open two dolphin windows on the same screen
3. Run `kde-builder --no-src --no-include-dependencies kio --run-tests` (assuming you have precompiled the dependencies)
4. Wait for the tests to start jerking the windows around

OBSERVED RESULT
kwin_wayland crashes most of the time

EXPECTED RESULT
No crash

SOFTWARE/OS VERSIONS
Linux: Arch Linux
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Comment 1 Antti Savolainen 2024-09-11 20:30:13 UTC
I found another way to reliably reproduce. Use the vesktop discord client, un-tile the vesktop window, go into a voice channel and start a screen share. Kwin will crash when you select which monitor you want to share.
Comment 2 Bug Janitor Service 2024-09-26 14:02:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6518
Comment 3 Vlad Zahorodnii 2024-09-26 14:15:58 UTC
(In reply to Antti Savolainen from comment #1)
> I found another way to reliably reproduce. Use the vesktop discord client,
> un-tile the vesktop window, go into a voice channel and start a screen
> share. Kwin will crash when you select which monitor you want to share.

Can you also report this issue to krohnkite developers? It resizes closed windows, which what it shouldn't do.
Comment 4 Antti Savolainen 2024-09-26 14:16:58 UTC
Will do.
Comment 5 Vlad Zahorodnii 2024-09-26 14:48:49 UTC
Git commit f339c4281f6c0513e1b847599f28f750eec01923 by Vlad Zahorodnii.
Committed on 26/09/2024 at 14:41.
Pushed by vladz into branch 'master'.

Guard closed windows against move and resize operations

A closed window cannot react to new geometry, also requesting new
geometry can involve accessing resources that are gone/deleted now.

Scripts trying to move or resize a closed window is a bug though.

M  +12   -0    src/window.cpp

https://invent.kde.org/plasma/kwin/-/commit/f339c4281f6c0513e1b847599f28f750eec01923
Comment 6 Vlad Zahorodnii 2024-09-26 15:12:26 UTC
Git commit 2d4d2913a02917d092f9d00754a9fe53a831597d by Vlad Zahorodnii.
Committed on 26/09/2024 at 15:01.
Pushed by vladz into branch 'Plasma/6.2'.

Guard closed windows against move and resize operations

A closed window cannot react to new geometry, also requesting new
geometry can involve accessing resources that are gone/deleted now.

Scripts trying to move or resize a closed window is a bug though.


(cherry picked from commit f339c4281f6c0513e1b847599f28f750eec01923)

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>

M  +12   -0    src/window.cpp

https://invent.kde.org/plasma/kwin/-/commit/2d4d2913a02917d092f9d00754a9fe53a831597d
Comment 7 Antti Savolainen 2024-09-27 01:47:33 UTC
Here's the bug report
https://github.com/anametologin/krohnkite/issues/79