From 5aa4956cd3ad42e6e511625fc548f55bf95a6575 Mon Sep 17 00:00:00 2001 From: furszy Date: Mon, 7 Apr 2025 11:38:48 -0400 Subject: [PATCH] gui: crash fix, disconnect numBlocksChanged() signal during shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The crash stems from the order of the shutdown procedure: We first unset the client model, then destroy the wallet controller—but we leave the internal wallet models ('m_wallets') untouched for a brief period. As a result, there’s a point in time where views still have connected signals and access to wallet models that are not connected to any wallet controller. Now.. since the clientModel is only replaced with nullptr locally and not destroyed yet, signals like numBlocksChanged can still emit. Thus, when wallet views receive them, they see a non-null wallet model ptr, and proceed to call backend functions from a model that is being torn down. As the shutdown procedure begins by unsetting clientModel from all views. It’s safe to ignore events when clientModel is nullptr. Github-Pull: gui#864 Rebased-From: 71656bdfaa6bfe08ce9651246a3ef606f923351b --- src/qt/sendcoinsdialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 0ee1b359fa9..1da03b8e3bc 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -851,6 +851,10 @@ void SendCoinsDialog::updateCoinControlState() } void SendCoinsDialog::updateNumberOfBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype, SynchronizationState sync_state) { + // During shutdown, clientModel will be nullptr. Attempting to update views at this point may cause a crash + // due to accessing backend models that might no longer exist. + if (!clientModel) return; + // Process event if (sync_state == SynchronizationState::POST_INIT) { updateSmartFeeLabel(); }