From 26be258bf99b2d703398b783b1fa8d6fec16bc62 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 9 Aug 2021 10:33:50 +0300 Subject: [PATCH] Core: Fix crash on shutdown ProcessReapers waits for all the processes to terminate, and in the mean time, it processes events. This is done after Core has already been terminated, but QObject dtor has not been called yet, so not all signal connections are disconnected. Crash trace: 1 QWidget::actions Qt5Widgets 0x7ff93a662fe9 2 Core::Internal::MenuActionContainer::updateInternal actioncontainer.cpp 482 0x7ff93158be03 3 Core::Internal::ActionContainerPrivate::update actioncontainer.cpp 417 0x7ff93158bd72 4 QMetaCallEvent::placeMetaCall Qt5Core 0x7ff939b9ac34 5 QObject::event Qt5Core 0x7ff939b995c1 6 QApplicationPrivate::notify_helper Qt5Widgets 0x7ff93a644990 7 QApplication::notify Qt5Widgets 0x7ff93a643a13 8 QCoreApplication::notifyInternal2 Qt5Core 0x7ff939b72aca 9 QCoreApplicationPrivate::sendPostedEvents Qt5Core 0x7ff939b74845 10 qt_plugin_query_metadata qwindows 0x7ff960422dff 11 QEventDispatcherWin32::processEvents Qt5Core 0x7ff939bbba5a 12 qt_plugin_query_metadata qwindows 0x7ff960422dd9 13 Core::Internal::ProcessReapers::~ProcessReapers reaper.cpp 134 0x7ff9317b54ee 14 Core::Internal::CorePlugin::~CorePlugin coreplugin.cpp 114 0x7ff9315a705c 15 Core::Internal::CorePlugin::`scalar deleting destructor' Core 0x7ff9315a8584 16 ExtensionSystem::Internal::PluginSpecPrivate::kill pluginspec.cpp 1125 0x7ff95299a160 17 ExtensionSystem::Internal::PluginManagerPrivate::loadPlugin pluginmanager.cpp 1608 0x7ff95298e2ad 18 ExtensionSystem::Internal::PluginManagerPrivate::deleteAll pluginmanager.cpp 1061 0x7ff9529885f5 19 ExtensionSystem::Internal::PluginManagerPrivate::shutdown pluginmanager.cpp 1397 0x7ff95299463f 20 QObject::qt_static_metacall Qt5Core 0x7ff939b91d49 21 QCoreApplicationPrivate::execCleanup Qt5Core 0x7ff939b71b25 22 QCoreApplication::exec Qt5Core 0x7ff939b71aaf 23 main main.cpp 762 0x7ff734b31bf7 24 WinMain qtcreator 0x7ff734b38407 25 __scrt_common_main_seh exe_common.inl 288 0x7ff734b3716a 26 BaseThreadInitThunk KERNEL32 0x7ff9a8806fd4 27 RtlUserThreadStart ntdll 0x7ff9a8adcec1 Change-Id: I7cf32f57354ee9e2507a2883078f0818fc5d6116 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/coreplugin.cpp | 2 ++ src/plugins/coreplugin/coreplugin.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 647636b8f1a..4f294b756d3 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -96,11 +96,13 @@ CorePlugin::CorePlugin() qRegisterMetaType(); qRegisterMetaType(); m_instance = this; + m_reaper = new ProcessReapers; setupSystemEnvironment(); } CorePlugin::~CorePlugin() { + delete m_reaper; IWizardFactory::destroyFeatureProvider(); Find::destroy(); diff --git a/src/plugins/coreplugin/coreplugin.h b/src/plugins/coreplugin/coreplugin.h index f8f9dab8a52..669244e767b 100644 --- a/src/plugins/coreplugin/coreplugin.h +++ b/src/plugins/coreplugin/coreplugin.h @@ -26,7 +26,6 @@ #pragma once #include -#include "reaper_p.h" #include #include @@ -45,6 +44,7 @@ namespace Internal { class EditMode; class MainWindow; class Locator; +class ProcessReapers; class CorePlugin : public ExtensionSystem::IPlugin { @@ -93,7 +93,7 @@ private: MainWindow *m_mainWindow = nullptr; EditMode *m_editMode = nullptr; Locator *m_locator = nullptr; - ProcessReapers m_reaper; + ProcessReapers *m_reaper = nullptr; Utils::Environment m_startupSystemEnvironment; Utils::EnvironmentItems m_environmentChanges; };