https://bugs.kde.org/show_bug.cgi?id=525753

            Bug ID: 525753
           Summary: kwin_wayland crashes randomly when closing a window
                    from the titlebar close button
    Classification: Plasma
           Product: kwin
      Version First unspecified
       Reported In:
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

STEPS TO REPRODUCE
1. Try to close a window with its titlebar close button.
2. It crashes (before you click). When I try to make it crash, it usually does
not, but it happens several times a day for the past few weeks, possibly since
I started living on master.

SOFTWARE/OS VERSIONS
kwin: git master, commit `cd18e4a1a620f671c3af9dc69e1df888a056c8be`
Operating System: Fedora Linux 44
KDE Plasma Version: 6.7.5
KDE Frameworks Version: 6.31.0
Qt Version: 6.11.2
Kernel Version: 7.2.4-200.fc44.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × Intel® Core™ i9-9880H CPU @ 2.30GHz
Memory: 64 GiB of RAM (62.5 GiB usable)
Graphics Processor 1: Intel® UHD Graphics 630
Graphics Processor 2: NVIDIA GeForce GTX 1650 with Max-Q Design

ADDITIONAL INFORMATION
I use Zren's Material Decoration, not sure it matters.
https://github.com/guiodic/material-decoration
not sure if it is relevant.

These are all the occurances (I think - the number of lines about corresponds
to how many times it feels like it has happened):
coredumpctl list kwin_wayland
Tue 2026-07-21 11:55:22 CEST  226501 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-07-23 10:04:41 CEST  266920 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sun 2026-07-26 10:06:41 CEST  494976 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-07-27 09:15:25 CEST  702987 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-07-30 14:18:38 CEST   16597 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-07-30 19:02:19 CEST   61178 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-07-31 00:24:49 CEST  131977 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sun 2026-08-16 22:06:43 CEST   31595 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Wed 2026-08-19 16:51:03 CEST  380349 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Wed 2026-08-19 21:05:25 CEST  458953 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-22 14:50:56 CEST  308904 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-22 16:22:53 CEST  333648 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-08-24 21:29:31 CEST  344145 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Wed 2026-08-26 10:51:08 CEST  929814 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-08-28 16:01:32 CEST   22873 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-08-28 16:10:32 CEST  118847 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 11:57:18 CEST  243258 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 11:57:46 CEST  306093 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 12:13:22 CEST  308636 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 12:14:39 CEST  316416 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 12:35:13 CEST  325589 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 12:51:28 CEST  329763 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-08-29 12:51:58 CEST  336437 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sun 2026-08-30 16:39:52 CEST  385919 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-08-31 02:14:49 CEST  922628 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-08-31 02:23:05 CEST  933556 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-08-31 13:22:23 CEST   84735 1000 1000 SIGABRT missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-08-31 22:03:25 CEST  285692 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-08-31 23:14:34 CEST  473078 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Tue 2026-09-01 09:45:48 CEST  495764 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Tue 2026-09-01 19:09:40 CEST  530432 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-09-05 00:33:44 CEST 2067724 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-09-05 11:16:14 CEST 2091908 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sun 2026-09-06 23:40:33 CEST 2556589 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-07 00:11:40 CEST 2576844 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-07 10:06:17 CEST 2581273 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-07 19:45:22 CEST 2653551 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-07 23:36:57 CEST 2809762 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Tue 2026-09-08 01:40:57 CEST 3090635 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Tue 2026-09-08 02:20:02 CEST 3141659 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Tue 2026-09-08 12:54:41 CEST 3157023 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Tue 2026-09-08 15:02:54 CEST 3220929 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Wed 2026-09-09 12:11:02 CEST 3754330 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Wed 2026-09-09 13:15:41 CEST 3846392 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Wed 2026-09-09 17:54:48 CEST 3875632 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-09-10 18:17:20 CEST   20342 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-09-10 19:01:40 CEST   60557 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-09-10 19:05:50 CEST   90836 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-09-10 19:52:39 CEST  119635 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Thu 2026-09-10 22:54:07 CEST  171544 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-09-11 11:27:43 CEST  216781 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-09-11 11:31:47 CEST  492888 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-09-11 19:25:16 CEST   83092 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-09-11 19:25:53 CEST  182886 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Fri 2026-09-11 21:17:33 CEST  184531 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Sat 2026-09-12 02:03:14 CEST  477002 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 02:15:07 CEST   53302 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 19:54:20 CEST 2465954 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 20:08:05 CEST  340829 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 20:12:18 CEST  351167 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 20:15:15 CEST  356482 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 20:40:43 CEST  360038 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 21:32:51 CEST  375636 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 21:50:46 CEST  413509 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 22:02:41 CEST  421245 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 22:21:32 CEST  428659 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 22:30:48 CEST  442199 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 23:08:59 CEST  453485 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 23:23:15 CEST  478313 1000 1000 SIGSEGV missing 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland     -
Mon 2026-09-14 23:23:33 CEST  484848 1000 1000 SIGSEGV present 
/home/drew/Zdroje_a_programy/dev/kde/usr/bin/kwin_wayland 10.4M

I sent an automatic report at least twice, not sure if it can be paired.

The backtrace:

0x00007fd5bc4e9287 in ??? () at /lib64/libnvidia-allocator.so.1
#1  0x00007fd5d6b11c11 in KWin::GbmGraphicsBuffer::~GbmGraphicsBuffer () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/core/gbmgraphicsbufferallocator.cpp:255
#2  0x00007fd5d6b11c3e in KWin::GbmGraphicsBuffer::~GbmGraphicsBuffer () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/core/gbmgraphicsbufferallocator.cpp:256
#3  0x00007fd5d6dcf8ed in KWin::GraphicsBufferRef::~GraphicsBufferRef () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/core/graphicsbuffer.h:179
#4  std::destroy_at<KWin::GraphicsBufferRef> () at
/usr/include/c++/16/bits/stl_construct.h:88
#5  std::_Destroy<KWin::GraphicsBufferRef> () at
/usr/include/c++/16/bits/stl_construct.h:164
#6  std::_Destroy<KWin::GraphicsBufferRef*> () at
/usr/include/c++/16/bits/stl_construct.h:226
#7  std::_Destroy<KWin::GraphicsBufferRef*, KWin::GraphicsBufferRef> () at
/usr/include/c++/16/bits/alloc_traits.h:1085
#8  std::vector<KWin::GraphicsBufferRef,
std::allocator<KWin::GraphicsBufferRef> >::~vector () at
/usr/include/c++/16/bits/stl_vector.h:792
#9  KWin::VulkanQueue::SubmittedCommand::~SubmittedCommand () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/vulkan/vulkan_queue.h:43
#10 std::default_delete<KWin::VulkanQueue::SubmittedCommand>::operator() () at
/usr/include/c++/16/bits/unique_ptr.h:92
#11 std::default_delete<KWin::VulkanQueue::SubmittedCommand>::operator() () at
/usr/include/c++/16/bits/unique_ptr.h:86
#12 std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> >::~unique_ptr () at
/usr/include/c++/16/bits/unique_ptr.h:408
#13 std::destroy_at<std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> > > () at
/usr/include/c++/16/bits/stl_construct.h:88
#14 std::_Destroy<std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> > > () at
/usr/include/c++/16/bits/stl_construct.h:164
#15 std::_Destroy<std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> >*> () at
/usr/include/c++/16/bits/stl_construct.h:226
#16 std::_Destroy<std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> >*,
std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> > > () at
/usr/include/c++/16/bits/alloc_traits.h:1085
#17 std::vector<std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> >,
std::allocator<std::unique_ptr<KWin::VulkanQueue::SubmittedCommand,
std::default_delete<KWin::VulkanQueue::SubmittedCommand> > > >::~vector () at
/usr/include/c++/16/bits/stl_vector.h:792
#18 KWin::VulkanQueue::~VulkanQueue () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/vulkan/vulkan_queue.cpp:27
#19 0x00007fd5d6dbc06e in std::default_delete<KWin::VulkanQueue>::operator() ()
at /usr/include/c++/16/bits/unique_ptr.h:92
#20 std::default_delete<KWin::VulkanQueue>::operator() () at
/usr/include/c++/16/bits/unique_ptr.h:86
#21 std::__uniq_ptr_impl<KWin::VulkanQueue,
std::default_delete<KWin::VulkanQueue> >::reset () at
/usr/include/c++/16/bits/unique_ptr.h:204
#22 std::unique_ptr<KWin::VulkanQueue, std::default_delete<KWin::VulkanQueue>
>::reset () at /usr/include/c++/16/bits/unique_ptr.h:530
#23 KWin::VulkanDevice::~VulkanDevice () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/vulkan/vulkan_device.cpp:42
#24 0x00007fd5d6dbc3ee in KWin::VulkanDevice::~VulkanDevice () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/vulkan/vulkan_device.cpp:46
#25 0x00007fd5d6b3b34f in std::default_delete<KWin::VulkanDevice>::operator()
() at /usr/include/c++/16/bits/unique_ptr.h:92
#26 std::unique_ptr<KWin::VulkanDevice, std::default_delete<KWin::VulkanDevice>
>::~unique_ptr () at /usr/include/c++/16/bits/unique_ptr.h:408
#27 KWin::RenderDevice::~RenderDevice () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/core/renderdevice.cpp:110
#28 0x00007fd5d6b3b4be in KWin::RenderDevice::~RenderDevice () at
/home/drew/Zdroje_a_programy/dev/kde/src/kwin/src/core/renderdevice.cpp:110
#29 0x00007fd5d6b12d4e in std::default_delete<KWin::RenderDevice>::operator()
() at /usr/include/c++/16/bits/unique_ptr.h:92
#30 std::unique_ptr<KWin::RenderDevice, std::default_delete<KWin::RenderDevice>
>::~unique_ptr () at /usr/include/c++/16/bits/unique_ptr.h:408
#31 std::destroy_at<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> > > () at
/usr/include/c++/16/bits/stl_construct.h:88
#32 std::_Destroy<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> > > () at
/usr/include/c++/16/bits/stl_construct.h:164
#33 std::_Destroy<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> >*> () at
/usr/include/c++/16/bits/stl_construct.h:226
#34 std::_Destroy<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> >*, std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> > > ()
at /usr/include/c++/16/bits/alloc_traits.h:1085
#35 std::vector<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> >,
std::allocator<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> > > >::_M_erase_at_end () at
/usr/include/c++/16/bits/stl_vector.h:2233
#36 std::vector<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> >,
std::allocator<std::unique_ptr<KWin::RenderDevice,
std::default_delete<KWin::RenderDevice> >

I had LLM debug it and it added debugging and then proposed a patch:

diff --git i/src/placementtracker.cpp w/src/placementtracker.cpp
index 534bc61a8f..bf27f40bb6 100644
--- i/src/placementtracker.cpp
+++ w/src/placementtracker.cpp
@@ -8,9 +8,12 @@
*/
#include "placementtracker.h"
#include "core/output.h"
+#include "utils/common.h"
#include "window.h"
#include "workspace.h"

+#include <cstdio>
+
namespace KWin
{

@@ -35,6 +38,8 @@ PlacementTracker::WindowData
PlacementTracker::dataForWindow(Window *window) con

void PlacementTracker::add(Window *window)
{
+    qCWarning(KWIN_CORE) << "PlacementTracker::add() enter" <<
static_cast<const void *>(window); // TEMPORARY: reentrancy debugging, avoid
touching window until after the null/vtable check below
+    fflush(stderr);
if (window->isUnmanaged() || window->isAppletPopup() ||
window->isSpecialWindow()) {
return;
}
diff --git i/src/plugins/qpa/window.cpp w/src/plugins/qpa/window.cpp
index f5cdbf80aa..715bf6394b 100644
--- i/src/plugins/qpa/window.cpp
+++ w/src/plugins/qpa/window.cpp
@@ -22,6 +22,7 @@

#include <logging.h>

+#include <cstdio>
#include <libdrm/drm_fourcc.h>
#include <qpa/qwindowsysteminterface.h>

@@ -152,9 +153,23 @@ void Window::map()
}

m_handle = new InternalWindow(window());
+    qCCritical(KWIN_QPA) << "map() enter" << this << m_handle.get();
+    fflush(stderr);

+    m_mapping = true;
m_exposed = true;
QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(),
geometry().size()));
+    m_mapping = false;
+
+    qCCritical(KWIN_QPA) << "map() leave" << this << m_handle.get();
+    fflush(stderr);
+
+    if (m_pendingUnmap) {
+        m_pendingUnmap = false;
+        qCCritical(KWIN_QPA) << "map() running deferred unmap()" << this;
+        fflush(stderr);
+        unmap();
+    }
}

void Window::unmap()
@@ -163,6 +178,16 @@ void Window::unmap()
return;
}

+    qCCritical(KWIN_QPA) << "unmap()" << this << m_handle.get() << "reentrant
during map():" << m_mapping;
+    fflush(stderr);
+
+    if (m_mapping) {
+        // map() is still further up the call stack using m_handle (see
BackingStore::flush()),
+        // so destroying it now would free it out from under that code. Defer
until map() is done.
+        m_pendingUnmap = true;
+        return;
+    }
+
m_handle->destroyWindow();
m_handle = nullptr;

diff --git i/src/plugins/qpa/window.h w/src/plugins/qpa/window.h
index f24fe03cc7..69996b9ae2 100644
--- i/src/plugins/qpa/window.h
+++ w/src/plugins/qpa/window.h
@@ -54,6 +54,8 @@ class Window : public QPlatformWindow
quint32 m_windowId;
qreal m_scale = 1;
bool m_exposed = false;
+    bool m_mapping = false; // guards against unmap() deleting m_handle while
map() is still using it
+    bool m_pendingUnmap = false;
};

}

It produced this log:

Sep 14 22:31:12.338858 GreenOne kwin_wayland[453485]: PlacementTracker::add()
enter 0x7f909a304180
Sep 14 22:31:12.821245 GreenOne kwin_wayland[453485]: map() enter
QPlatformSurface(0x7f9098b112e0, class=QSurface::Window,
type=QSurface::OpenGLSurface, window=QQuickWindowQmlImpl_QML_142>
Sep 14 22:31:12.875288 GreenOne kwin_wayland[453485]: PlacementTracker::add()
enter 0x7f9098b5ce00
Sep 14 22:31:12.875841 GreenOne kwin_wayland[453485]: map() leave
QPlatformSurface(0x7f9098b112e0, class=QSurface::Window,
type=QSurface::OpenGLSurface, window=QQuickWindowQmlImpl_QML_142>
Sep 14 22:31:13.042458 GreenOne kwin_wayland[453485]: unmap()
QPlatformSurface(0x7f9098b112e0, class=QSurface::Window,
type=QSurface::OpenGLSurface, window=QQuickWindowQmlImpl_QML_142(0x7>
Sep 14 22:31:13.233927 GreenOne kwin_wayland[453485]: PlacementTracker::add()
enter 0x7f9098fe3890
Sep 14 22:31:13.266644 GreenOne kwin_wayland[453485]: PlacementTracker::add()
enter 0x7f9098fe8070

The LLM claims it is all a race in src/plugins/qpa/window.cpp in map() and
unmap()

I am now running the patched version and will report back if the issue reoccurs
or not (in a few days, I should be fairly sure).

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to