From f75e53af60e715030f942c70db8b04cf5cf300c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 10 Nov 2015 13:54:26 +0100 Subject: [PATCH] [wayland] Ensure to not call into x11 on Compositor tear-down During Compositor tear down Xwayland is already destroyed. Thus it doesn't make sense to try to delete the support properties: either it freezes in xcb or it crashes because the connection is null. At the same time we also ensure that the connection internally is reset to null. Note: the one in kwinglobals.h caches and could cause use-after-free errors. Any tear-down code must be migrated to kwinApp()->x11Connection(). --- autotests/wayland/kwin_wayland_test.cpp | 1 + composite.cpp | 8 +++++--- main_wayland.cpp | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/autotests/wayland/kwin_wayland_test.cpp b/autotests/wayland/kwin_wayland_test.cpp index 676bedc72c..88facd1faf 100644 --- a/autotests/wayland/kwin_wayland_test.cpp +++ b/autotests/wayland/kwin_wayland_test.cpp @@ -56,6 +56,7 @@ WaylandTestApplication::~WaylandTestApplication() Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); destroyAtoms(); xcb_disconnect(x11Connection()); + setX11Connection(nullptr); } if (m_xwaylandProcess) { m_xwaylandProcess->terminate(); diff --git a/composite.cpp b/composite.cpp index 2ed44ceaf4..77d66d4ae5 100644 --- a/composite.cpp +++ b/composite.cpp @@ -443,9 +443,11 @@ void Compositor::deleteUnusedSupportProperties() m_unusedSupportPropertyTimer.start(); return; } - foreach (const xcb_atom_t &atom, m_unusedSupportProperties) { - // remove property from root window - xcb_delete_property(connection(), rootWindow(), atom); + if (kwinApp()->x11Connection()) { + foreach (const xcb_atom_t &atom, m_unusedSupportProperties) { + // remove property from root window + xcb_delete_property(connection(), rootWindow(), atom); + } } } diff --git a/main_wayland.cpp b/main_wayland.cpp index 946598f44f..41fc7e5158 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -80,6 +80,7 @@ ApplicationWayland::~ApplicationWayland() Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); destroyAtoms(); xcb_disconnect(x11Connection()); + setX11Connection(nullptr); } if (m_xwaylandProcess) { m_xwaylandProcess->terminate();