Repository navigation
Description
Quitting while a modal dialog is open can delete the wallet views underneath that dialog's nested event loop. Objects on that loop caller's stack are then used after they are freed, or destroyed twice. Line numbers are at 1.x.x 21fee6ee8e.
What happens
BitcoinApplication::requestShutdown() calls window->removeAllWallets() (src/qt/bitcoin.cpp:371). That reaches WalletFrame::removeWallet and delete walletView (src/qt/walletframe.cpp:130). It runs inside whatever nested event loop is active, for example:
SendCoinsDialog::prepareTransactionFinishedwaiting inSendConfirmationDialog::exec();- the
QMessageBoxand the file dialog thatSendCoinsDialog::presentPSBTkeeps on the stack; - the
AskPassphraseDialogthatWalletViewkeeps on the stack; - the
AddressBookPagethatSendCoinsEntrykeeps on the stack.
Deleting the parent destroys these objects while their exec() is still on the stack. Code after exec() then runs on a deleted object.
Calling removeAllWallets() from requestShutdown() is qbit-specific. Upstream only deletes the wallet controller there.
Triggers
- Guarded: the poll that turns RPC
stopand SIGTERM into a shutdown waits while a modal widget is active (src/qt/bitcoin.cpp:267), and the tray menu disables its actions in that case. - Not guarded: two triggers have no such check:
- The application's
QEvent::Quit(src/qt/bitcoin.cpp:472), which the platform sends when it asks the app to terminate, for example macOS Dock ▸ Quit, logout, or a Quit Apple event. quitAction→quitRequested→requestShutdown(src/qt/bitcoingui.cpp:410,src/qt/bitcoin.cpp:263). File ▸ Exit can be pressed through accessibility (VoiceOver, UI automation) behind the modal dialog, the same bypass as the Release v1.0.1: test results, remaining fixes, and release gates #174 A11 abort.
- The application's
Evidence
- A Qt test under AddressSanitizer deletes the send dialog from the confirmation's nested loop and reports
heap-use-after-freeinSendCoinsDialog::finishSendWithPreparedTransaction. The send-dialog fix for Release v1.0.1: test results, remaining fixes, and release gates #174 guards that one call site. - The other sites were found by reading the code and have not been reproduced in a running app.
Expected
- A quit request does not delete GUI objects underneath a nested event loop. Either it is deferred while a modal widget is active, as the shutdown poll already does, or the modal dialogs are closed and their loops unwound before the wallet views are deleted.
- Busy operations (send preparation, PSBT signing, encryption) finish or are cancelled cleanly, and the app then exits without a crash.
- This is Release v1.0.1: test results, remaining fixes, and release gates #174's check "Quit during background work" (runbook C4): "the app exits, or visibly waits for the operation, without crashing".
Found during the #174 v1.0.1 release work.
Activity
qt: wait for open dialogs before shutdown and wallet unload
qt: wait for open dialogs before shutdown and wallet unload
qt: wait for open dialogs before shutdown and wallet unload (#354)
doc: cover the PRs merged since the last v1.0.1 notes update
kiwidream commentedon Nov 11, 2026
Fixed on
1.x.xby #354 (73c704b4e4), which ships in v1.0.1: a platform or menu quit, and a wallet unload, now wait while a dialog's nested event loop is running and are carried out once it has closed.Closing by hand, because a merge into
1.x.xdoes not close issues automatically.doc: cover the PRs merged since the last v1.0.1 notes update
release: prepare v1.0.1 (#181)
qt: wait for open dialogs before shutdown and wallet unload (#354)
release: prepare v1.0.1 (#181)