From 0bdfe776ec5cb9680564db9d9499ef6ef77626a7 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 18 Sep 2024 14:20:28 +0200 Subject: [PATCH] Ios: Fix a possible crash on shutdown Since IosDeviceManager is a static object, it's destructed after the shutdown phase has passed. But since the destructor of IosDeviceManager may be deleting the running task trees containing the running processes, it may crash since the ProcessReaper is gone at this stage. To fix it, create IosDeviceManager on heap and pass a shutdown guard as a parent, so that it's deleted before the ProcessReaper is gone. Fixes: QTCREATORBUG-31484 Change-Id: Ieaac16331304cffbe3f50291d7d914aebfa0b2e3 Reviewed-by: Marcus Tillmanns --- src/plugins/ios/iosdevice.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp index c114385eca1..abf0c0dc79c 100644 --- a/src/plugins/ios/iosdevice.cpp +++ b/src/plugins/ios/iosdevice.cpp @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -589,8 +591,8 @@ void IosDeviceManager::updateUserModeDevices() IosDeviceManager *IosDeviceManager::instance() { - static IosDeviceManager obj; - return &obj; + static IosDeviceManager *theInstance = new IosDeviceManager(ExtensionSystem::shutdownGuard()); + return theInstance; } void IosDeviceManager::updateAvailableDevices(const QStringList &devices)