Bug 486631 - KWin crashes when accessing window caption while handling Window.visibleGeometryChanged() after workspace.windowRemoved() was triggered
Summary: KWin crashes when accessing window caption while handling Window.visibleGeome...
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: scripting (show other bugs)
Version: 6.0.4
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-05 16:52 UTC by Flupp
Modified: 2024-08-28 12:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Example script triggering a KWin crash. Grep for “potentially triggers KWin crash” to find the guilty line. (1.83 KB, application/zip)
2024-05-05 16:52 UTC, Flupp
Details
backtrace (36.26 KB, text/vnd.kde.kcrash-report)
2024-05-05 16:53 UTC, Flupp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Flupp 2024-05-05 16:52:20 UTC
Created attachment 169216 [details]
Example script triggering a KWin crash. Grep for “potentially triggers KWin crash” to find the guilty line.

Assume a handler function h() is connected to w.visibleGeometryChanged() for a particular window w in a KWin script. Accessing w.caption in h() crashes KWin when workspace.windowRemoved() was already triggered for w.

The issue might be more generic, i.e., accessing a window property after workspace.windowRemoved() was triggered for this window could lead to a KWin crash in general. However, one could ask: Is it a bug of the KWin script to access windows properties of a removed window? Is it expected that KWin scripts can crash KWin (rather than just the script)?


STEPS TO REPRODUCE

The attached KWin script can be used to trigger a crash when a window is removed. Caution: Be prepared to being able to disable the script again to avoid repeated unwanted KWin crashes, e.g. via kwriteconfig6 --file kwinrc --group Plugins --key kwin-scripting-event-loggerEnabled false; qdbus org.kde.KWin /KWin reconfigure.


OBSERVED RESULT

KWin crashes.


EXPECTED RESULT

Nothing crashes – neither KWin nor the script. However, this is debatable (see above).


SOFTWARE/OS VERSIONS

Operating System: Arch Linux
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.8.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-4790 CPU @ 3.60GHz
Memory: 23,4 GiB of RAM
Graphics Processor: VERDE
Manufacturer: ASUS
Product Name: All Series
Comment 1 Flupp 2024-05-05 16:53:09 UTC
Created attachment 169217 [details]
backtrace
Comment 2 Vlad Zahorodnii 2024-08-28 12:27:10 UTC
After the windowRemoved signal is emitted, you MUST NOT use the window anymore, the script must drop all its references for the window.

If a script holds a reference to a closed window, its lifetime won't be extended.