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 <eike.ziller@qt.io>
This commit is contained in:
Orgad Shaneh
2021-08-09 10:33:50 +03:00
committed by Orgad Shaneh
parent fa1d7958c3
commit 26be258bf9
2 changed files with 4 additions and 2 deletions

View File

@@ -96,11 +96,13 @@ CorePlugin::CorePlugin()
qRegisterMetaType<Utils::CommandLine>(); qRegisterMetaType<Utils::CommandLine>();
qRegisterMetaType<Utils::FilePath>(); qRegisterMetaType<Utils::FilePath>();
m_instance = this; m_instance = this;
m_reaper = new ProcessReapers;
setupSystemEnvironment(); setupSystemEnvironment();
} }
CorePlugin::~CorePlugin() CorePlugin::~CorePlugin()
{ {
delete m_reaper;
IWizardFactory::destroyFeatureProvider(); IWizardFactory::destroyFeatureProvider();
Find::destroy(); Find::destroy();

View File

@@ -26,7 +26,6 @@
#pragma once #pragma once
#include <qglobal.h> #include <qglobal.h>
#include "reaper_p.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <utils/environment.h> #include <utils/environment.h>
@@ -45,6 +44,7 @@ namespace Internal {
class EditMode; class EditMode;
class MainWindow; class MainWindow;
class Locator; class Locator;
class ProcessReapers;
class CorePlugin : public ExtensionSystem::IPlugin class CorePlugin : public ExtensionSystem::IPlugin
{ {
@@ -93,7 +93,7 @@ private:
MainWindow *m_mainWindow = nullptr; MainWindow *m_mainWindow = nullptr;
EditMode *m_editMode = nullptr; EditMode *m_editMode = nullptr;
Locator *m_locator = nullptr; Locator *m_locator = nullptr;
ProcessReapers m_reaper; ProcessReapers *m_reaper = nullptr;
Utils::Environment m_startupSystemEnvironment; Utils::Environment m_startupSystemEnvironment;
Utils::EnvironmentItems m_environmentChanges; Utils::EnvironmentItems m_environmentChanges;
}; };