From a7e18789cbd63fddb0b17abd4060f85f0920f5fd Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 12 Dec 2019 14:06:20 +0200 Subject: [PATCH] Fix crash in XRenderPictureData::~XRenderPictureData Summary: If the XRender scene has cross-faded a window, then, eventually, KWin/X11 will crash in the destructor of the XRenderPictureData class during tear down with the following message in the terminal ``` ASSERT: "qApp" in file /home/vlad/Workspace/KDE/src/kde/workspace/kwin/libkwineffects/kwinxrenderutils.cpp, line 163 ``` The crash happens because X11StandalonePlatform attempts to clean up XRender resources, including XRenderUtils::s_blendPicture, after the application object has been destroyed. In order to fix the crash, we have to destroy the platform object before the destructor of QCoreApplication is executed. Test Plan: - Enable maximize effect - Maximize a window - Replace the current instance of KWin/X11 with another one Without this patch, KWin/X11 crashes after the third step. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25768 --- main.cpp | 7 +++++++ main.h | 1 + 2 files changed, 8 insertions(+) diff --git a/main.cpp b/main.cpp index 8799410677..e53342baaa 100644 --- a/main.cpp +++ b/main.cpp @@ -161,6 +161,7 @@ Application::~Application() { delete options; destroyAtoms(); + destroyPlatform(); } void Application::destroyAtoms() @@ -169,6 +170,12 @@ void Application::destroyAtoms() atoms = nullptr; } +void Application::destroyPlatform() +{ + delete m_platform; + m_platform = nullptr; +} + void Application::resetCrashesCount() { crashes = 0; diff --git a/main.h b/main.h index ba6bbba2ff..3033ed66f6 100644 --- a/main.h +++ b/main.h @@ -231,6 +231,7 @@ protected: emit x11ConnectionChanged(); } void destroyAtoms(); + void destroyPlatform(); void setTerminating() { m_terminating = true;