mirror of https://github.com/procxx/kepka.git
				
				
				
			Alpha 1.0.16: fighting crashes.
An attempt to fix a crash in MTP::Instance destructor + additional logging there to find out how this crash happens.
This commit is contained in:
		
							parent
							
								
									2fa2fa41c5
								
							
						
					
					
						commit
						d254058690
					
				| 
						 | 
					@ -9,7 +9,7 @@
 | 
				
			||||||
  <Identity Name="TelegramDesktop"
 | 
					  <Identity Name="TelegramDesktop"
 | 
				
			||||||
    ProcessorArchitecture="x64"
 | 
					    ProcessorArchitecture="x64"
 | 
				
			||||||
    Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB"
 | 
					    Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB"
 | 
				
			||||||
    Version="1.0.15.0" />
 | 
					    Version="1.0.16.0" />
 | 
				
			||||||
  <Properties>
 | 
					  <Properties>
 | 
				
			||||||
    <DisplayName>Telegram Desktop</DisplayName>
 | 
					    <DisplayName>Telegram Desktop</DisplayName>
 | 
				
			||||||
    <PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>
 | 
					    <PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,8 +34,8 @@ IDI_ICON1               ICON                    "..\\art\\icon256.ico"
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VS_VERSION_INFO VERSIONINFO
 | 
					VS_VERSION_INFO VERSIONINFO
 | 
				
			||||||
 FILEVERSION 1,0,15,0
 | 
					 FILEVERSION 1,0,16,0
 | 
				
			||||||
 PRODUCTVERSION 1,0,15,0
 | 
					 PRODUCTVERSION 1,0,16,0
 | 
				
			||||||
 FILEFLAGSMASK 0x3fL
 | 
					 FILEFLAGSMASK 0x3fL
 | 
				
			||||||
#ifdef _DEBUG
 | 
					#ifdef _DEBUG
 | 
				
			||||||
 FILEFLAGS 0x1L
 | 
					 FILEFLAGS 0x1L
 | 
				
			||||||
| 
						 | 
					@ -52,10 +52,10 @@ BEGIN
 | 
				
			||||||
        BEGIN
 | 
					        BEGIN
 | 
				
			||||||
            VALUE "CompanyName", "Telegram Messenger LLP"
 | 
					            VALUE "CompanyName", "Telegram Messenger LLP"
 | 
				
			||||||
            VALUE "FileDescription", "Telegram Desktop"
 | 
					            VALUE "FileDescription", "Telegram Desktop"
 | 
				
			||||||
            VALUE "FileVersion", "1.0.15.0"
 | 
					            VALUE "FileVersion", "1.0.16.0"
 | 
				
			||||||
            VALUE "LegalCopyright", "Copyright (C) 2014-2017"
 | 
					            VALUE "LegalCopyright", "Copyright (C) 2014-2017"
 | 
				
			||||||
            VALUE "ProductName", "Telegram Desktop"
 | 
					            VALUE "ProductName", "Telegram Desktop"
 | 
				
			||||||
            VALUE "ProductVersion", "1.0.15.0"
 | 
					            VALUE "ProductVersion", "1.0.16.0"
 | 
				
			||||||
        END
 | 
					        END
 | 
				
			||||||
    END
 | 
					    END
 | 
				
			||||||
    BLOCK "VarFileInfo"
 | 
					    BLOCK "VarFileInfo"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VS_VERSION_INFO VERSIONINFO
 | 
					VS_VERSION_INFO VERSIONINFO
 | 
				
			||||||
 FILEVERSION 1,0,15,0
 | 
					 FILEVERSION 1,0,16,0
 | 
				
			||||||
 PRODUCTVERSION 1,0,15,0
 | 
					 PRODUCTVERSION 1,0,16,0
 | 
				
			||||||
 FILEFLAGSMASK 0x3fL
 | 
					 FILEFLAGSMASK 0x3fL
 | 
				
			||||||
#ifdef _DEBUG
 | 
					#ifdef _DEBUG
 | 
				
			||||||
 FILEFLAGS 0x1L
 | 
					 FILEFLAGS 0x1L
 | 
				
			||||||
| 
						 | 
					@ -43,10 +43,10 @@ BEGIN
 | 
				
			||||||
        BEGIN
 | 
					        BEGIN
 | 
				
			||||||
            VALUE "CompanyName", "Telegram Messenger LLP"
 | 
					            VALUE "CompanyName", "Telegram Messenger LLP"
 | 
				
			||||||
            VALUE "FileDescription", "Telegram Desktop Updater"
 | 
					            VALUE "FileDescription", "Telegram Desktop Updater"
 | 
				
			||||||
            VALUE "FileVersion", "1.0.15.0"
 | 
					            VALUE "FileVersion", "1.0.16.0"
 | 
				
			||||||
            VALUE "LegalCopyright", "Copyright (C) 2014-2017"
 | 
					            VALUE "LegalCopyright", "Copyright (C) 2014-2017"
 | 
				
			||||||
            VALUE "ProductName", "Telegram Desktop"
 | 
					            VALUE "ProductName", "Telegram Desktop"
 | 
				
			||||||
            VALUE "ProductVersion", "1.0.15.0"
 | 
					            VALUE "ProductVersion", "1.0.16.0"
 | 
				
			||||||
        END
 | 
					        END
 | 
				
			||||||
    END
 | 
					    END
 | 
				
			||||||
    BLOCK "VarFileInfo"
 | 
					    BLOCK "VarFileInfo"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define BETA_VERSION_MACRO (0ULL)
 | 
					#define BETA_VERSION_MACRO (0ULL)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
constexpr int AppVersion = 1000015;
 | 
					constexpr int AppVersion = 1000016;
 | 
				
			||||||
constexpr str_const AppVersionStr = "1.0.15";
 | 
					constexpr str_const AppVersionStr = "1.0.16";
 | 
				
			||||||
constexpr bool AppAlphaVersion = true;
 | 
					constexpr bool AppAlphaVersion = true;
 | 
				
			||||||
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
 | 
					constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -170,6 +170,9 @@ private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SingleTimer _checkDelayedTimer;
 | 
						SingleTimer _checkDelayedTimer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Debug flag to find out how we end up crashing.
 | 
				
			||||||
 | 
						bool MustNotCreateSessions = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Instance::Private::Private(Instance *instance, DcOptions *options, Instance::Mode mode) : _instance(instance)
 | 
					Instance::Private::Private(Instance *instance, DcOptions *options, Instance::Mode mode) : _instance(instance)
 | 
				
			||||||
| 
						 | 
					@ -210,12 +213,14 @@ void Instance::Private::start(Config &&config) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (isKeysDestroyer()) {
 | 
						if (isKeysDestroyer()) {
 | 
				
			||||||
		for (auto &dc : _dcenters) {
 | 
							for (auto &dc : _dcenters) {
 | 
				
			||||||
 | 
								t_assert(!MustNotCreateSessions);
 | 
				
			||||||
			auto shiftedDcId = dc.first;
 | 
								auto shiftedDcId = dc.first;
 | 
				
			||||||
			auto session = std::make_unique<internal::Session>(_instance, shiftedDcId);
 | 
								auto session = std::make_unique<internal::Session>(_instance, shiftedDcId);
 | 
				
			||||||
			auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
 | 
								auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
 | 
				
			||||||
			it->second->start();
 | 
								it->second->start();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (_mainDcId != Config::kNoneMainDc) {
 | 
						} else if (_mainDcId != Config::kNoneMainDc) {
 | 
				
			||||||
 | 
							t_assert(!MustNotCreateSessions);
 | 
				
			||||||
		auto main = std::make_unique<internal::Session>(_instance, _mainDcId);
 | 
							auto main = std::make_unique<internal::Session>(_instance, _mainDcId);
 | 
				
			||||||
		_mainSession = main.get();
 | 
							_mainSession = main.get();
 | 
				
			||||||
		_sessions.emplace(_mainDcId, std::move(main));
 | 
							_sessions.emplace(_mainDcId, std::move(main));
 | 
				
			||||||
| 
						 | 
					@ -296,7 +301,9 @@ int32 Instance::Private::dcstate(ShiftedDcId shiftedDcId) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto it = _sessions.find(shiftedDcId);
 | 
						auto it = _sessions.find(shiftedDcId);
 | 
				
			||||||
	if (it != _sessions.cend()) return it->second->getState();
 | 
						if (it != _sessions.cend()) {
 | 
				
			||||||
 | 
							return it->second->getState();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return DisconnectedState;
 | 
						return DisconnectedState;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -383,6 +390,7 @@ void Instance::Private::killSession(ShiftedDcId shiftedDcId) {
 | 
				
			||||||
	if (checkIfMainAndKill(shiftedDcId)) {
 | 
						if (checkIfMainAndKill(shiftedDcId)) {
 | 
				
			||||||
		checkIfMainAndKill(_mainDcId);
 | 
							checkIfMainAndKill(_mainDcId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							t_assert(!MustNotCreateSessions);
 | 
				
			||||||
		auto main = std::make_unique<internal::Session>(_instance, _mainDcId);
 | 
							auto main = std::make_unique<internal::Session>(_instance, _mainDcId);
 | 
				
			||||||
		_mainSession = main.get();
 | 
							_mainSession = main.get();
 | 
				
			||||||
		_sessions.emplace(_mainDcId, std::move(main));
 | 
							_sessions.emplace(_mainDcId, std::move(main));
 | 
				
			||||||
| 
						 | 
					@ -492,6 +500,7 @@ void Instance::Private::addKeysForDestroy(AuthKeysList &&keys) {
 | 
				
			||||||
		auto dc = std::make_shared<internal::Dcenter>(_instance, dcId, std::move(key));
 | 
							auto dc = std::make_shared<internal::Dcenter>(_instance, dcId, std::move(key));
 | 
				
			||||||
		_dcenters.emplace(shiftedDcId, std::move(dc));
 | 
							_dcenters.emplace(shiftedDcId, std::move(dc));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							t_assert(!MustNotCreateSessions);
 | 
				
			||||||
		auto session = std::make_unique<internal::Session>(_instance, shiftedDcId);
 | 
							auto session = std::make_unique<internal::Session>(_instance, shiftedDcId);
 | 
				
			||||||
		auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
 | 
							auto it = _sessions.emplace(shiftedDcId, std::move(session)).first;
 | 
				
			||||||
		it->second->start();
 | 
							it->second->start();
 | 
				
			||||||
| 
						 | 
					@ -1113,6 +1122,7 @@ internal::Session *Instance::Private::getSession(ShiftedDcId shiftedDcId) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto it = _sessions.find(shiftedDcId);
 | 
						auto it = _sessions.find(shiftedDcId);
 | 
				
			||||||
	if (it == _sessions.cend()) {
 | 
						if (it == _sessions.cend()) {
 | 
				
			||||||
 | 
							t_assert(!MustNotCreateSessions);
 | 
				
			||||||
		it = _sessions.emplace(shiftedDcId, std::make_unique<internal::Session>(_instance, shiftedDcId)).first;
 | 
							it = _sessions.emplace(shiftedDcId, std::make_unique<internal::Session>(_instance, shiftedDcId)).first;
 | 
				
			||||||
		it->second->start();
 | 
							it->second->start();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1189,12 +1199,15 @@ void Instance::Private::clearGlobalHandlers() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Instance::Private::prepareToDestroy() {
 | 
					void Instance::Private::prepareToDestroy() {
 | 
				
			||||||
 | 
						// It accesses Instance in destructor, so it should be destroyed first.
 | 
				
			||||||
 | 
						_configLoader.reset();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (auto &session : base::take(_sessions)) {
 | 
						for (auto &session : base::take(_sessions)) {
 | 
				
			||||||
		session.second->kill();
 | 
							session.second->kill();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						_mainSession = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// It accesses Instance in destructor, so it should be destroyed first.
 | 
						MustNotCreateSessions = true;
 | 
				
			||||||
	_configLoader.reset();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Instance::Instance(DcOptions *options, Mode mode, Config &&config) : QObject()
 | 
					Instance::Instance(DcOptions *options, Mode mode, Config &&config) : QObject()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
AppVersion         1000015
 | 
					AppVersion         1000016
 | 
				
			||||||
AppVersionStrMajor 1.0
 | 
					AppVersionStrMajor 1.0
 | 
				
			||||||
AppVersionStrSmall 1.0.15
 | 
					AppVersionStrSmall 1.0.16
 | 
				
			||||||
AppVersionStr      1.0.15
 | 
					AppVersionStr      1.0.16
 | 
				
			||||||
AlphaChannel       1
 | 
					AlphaChannel       1
 | 
				
			||||||
BetaVersion        0
 | 
					BetaVersion        0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue