Repository navigation
Description
Acknowledgement
- I still think this issue should be opened here.
Summary
qbit-qt can enter a mutual wait when application shutdown overlaps successful wallet creation: the GUI thread waits for the wallet-controller worker to exit while that worker synchronously waits for the GUI thread to parent a newly created WalletModel.
A bounded Qt probe reproduced the underlying blocking-connection cycle. A full qbit-qt reproduction proving native/Cmd-Q reachability in the relevant timing window is still pending.
Impact
Quitting while a wallet is being created can leave qbit-qt hung indefinitely and require forced termination during a multi-stage durable operation. After restart, the user may not know whether wallet creation, encryption, descriptor setup, loading, or startup registration completed.
This is a bounded availability and recovery-state defect. No key-confidentiality failure has been demonstrated.
Evidence
- The affected code is identical on
mainand0.1.xas of July 10, 2026. - The mutual-wait mechanism is visible in the source.
- A bounded Qt probe reproduced the blocking-connection behavior.
- End-to-end native-Quit reachability still needs a latch-controlled qbit-qt test.
- Code refs:
src/qt/walletcontroller.cpp:39-66src/qt/walletcontroller.cpp:117-151src/qt/walletcontroller.cpp:246-279src/qt/guiutil.cpp:384-394src/qt/bitcoin.cpp:329-376src/qt/bitcoin.cpp:459-466src/wallet/wallet.cpp:221-234src/wallet/wallet.cpp:721-729
Failure Path
CreateWalletActivityschedules wallet creation on the wallet-controller worker.- Successful creation synchronously calls
NotifyWalletLoadedon that worker. - The controller's load-wallet callback enters
getOrCreateWallet, which callsQMetaObject::invokeMethodwithGUIUtil::blockingGUIThreadConnection()sosetParentruns on the GUI thread. - A native
QEvent::Quitcan callrequestShutdowndirectly, including while a modal dialog is active. requestShutdowndeletesWalletControlleron the GUI thread. Its destructor callsquit()and then blocks inwait()while the load-wallet handler is still connected.quit()does not interrupt the worker's already-running creation callback. The GUI thread waits for the worker, and the worker waits for the GUI thread to service the blocking invoke.
The strongest narrowing condition is timing: application Quit must reach teardown while the worker is in, or is about to enter, the blocking GUI-thread invocation. The source proves the cycle but not how reliably a production native-Quit event hits that window.
Reproduction
- Add latches around encrypted wallet creation immediately before
NotifyWalletLoadedand immediately before the blocking GUI-thread parent invocation. - Start wallet creation and pause at one latch.
- Deliver a native/Cmd-Q
QEvent::Quitso the GUI thread entersWalletControllerteardown. - Release the worker.
- Assert that qbit-qt exits within a fixed bound; on affected code, the GUI and worker can remain mutually blocked.
- Repeat at database creation, encryption, descriptor setup,
NotifyWalletLoaded, andAddWalletboundaries. - After each forced or clean restart, inspect
listwalletdir,listwallets,getwalletinfo, active-wallet selection, and startup settings.
Expected Behavior
Shutdown completes within a bounded time without forcing termination. After restart, durable wallet state and GUI/startup registration agree and clearly describe whether creation completed.
Suggested Fix
Define an explicit wallet-controller shutdown phase before joining the worker:
- stop accepting new load-wallet callbacks and guard model adoption once shutdown begins;
- remove the worker-to-GUI
BlockingQueuedConnectioncycle, or drain all model-adoption work while the GUI event loop can still service it; - make one thread explicitly own model creation and parenting; and
- join the activity worker only after no in-flight path can synchronously wait on the GUI thread.
Resetting the load-wallet handler is useful for preventing new callbacks, but the fix must also handle a callback that is already executing.
Verification
Add a latch-controlled Qt regression covering both notification-driven and activity-driven model adoption. Require bounded Quit at every durable creation boundary and an explainable listwalletdir / listwallets / getwalletinfo / startup state after restart. Also rerun ordinary wallet load, unload, create, restore, and GUI shutdown tests.
Activity