Repository navigation
Description
Issues, reports or feature requests related to the qbit GUI should be opened here only when they apply to this repository
- I still think this issue should be opened here
Report
Summary
qbit-qt can deadlock immediately after a correct wallet passphrase is entered. This was observed while creating a transaction with many inputs, but the deadlock occurs during wallet unlock, before transaction preparation or signing starts.
The deadlock involves the GUI thread performing the deferred initial P2MR keypool top-up while the wallet scheduler processes a connected block.
Environment
- qbit: v1.0.0, arm64 application bundle
- OS: macOS 26.4
- CPU: Apple M5 Max
- Wallet: encrypted descriptor wallet with P2MR keys and a pending deferred create-time keypool top-up
Steps to reproduce
- Open an encrypted wallet that has a deferred initial P2MR keypool top-up pending.
- In
qbit-qt, construct a transaction that requires the wallet to be unlocked. This was observed with a transaction containing many inputs. - Continue until the unlock-wallet dialog appears.
- Enter the correct wallet passphrase.
Current behaviour
The passphrase dialog accepts the password, but the GUI then stops responding indefinitely.
During the hang:
- The process is effectively idle rather than performing CPU-intensive PQC signing.
- No transaction-preparation or wallet-signing timing messages appear.
- No
walletpqcsigning worker threads are running. - Node and network activity remain alive.
- Wallet RPC calls block waiting for the wallet lock.
The final relevant sanitized log line is:
Running deferred create-time keypool top up to 1000 entries per active descriptor
The corresponding completion message is never logged.
Expected behaviour
Wallet unlock should complete without blocking the GUI. Deferred keypool maintenance should not deadlock with block processing, and transaction preparation should proceed after the wallet is unlocked.
Deadlock analysis
Two repeated process samples showed the same stable lock cycle.
GUI thread
The GUI thread follows approximately this path:
AskPassphraseDialog::accept
WalletModel::setWalletLocked
CWallet::Unlock
CWallet::RunPendingInitialKeyPoolTopUp
CWallet::RunPendingInitialKeyPoolTopUpStep
DescriptorScriptPubKeyMan::TopUp
DescriptorScriptPubKeyMan::TopUpWithInternalHintResult
DescriptorScriptPubKeyMan::TopUpWithDBPreparedResult
NotifyCanGetAddressesChanged
ReceiveCoinsDialog canGetAddressesChanged handler
CWallet::CanGetAddresses
std::recursive_mutex::lock
TopUpWithInternalHintResult holds cs_desc_man and an active SQLite write transaction. TopUpWithDBPreparedResult emits NotifyCanGetAddressesChanged() before the outer transaction is committed and before the descriptor lock is released.
Because this happens on the GUI thread, WalletModel uses an automatic/direct Qt invocation. The connected ReceiveCoinsDialog handler immediately calls wallet().canGetAddresses(), which tries to acquire cs_wallet.
Scheduler thread
At the same time, the scheduler thread follows approximately:
CWallet::blockConnected
CWallet::AddToWalletIfInvolvingMe
CWallet::AddToWallet
CWallet::IncOrderPosNext
WalletBatch::WriteOrderPosNext
DatabaseBatch::Write
SQLiteBatch::WriteKey
atomic semaphore wait
blockConnected() holds cs_wallet. Its wallet database write then waits for the SQLite writer currently held by the GUI thread's keypool top-up.
The resulting cycle is:
GUI thread:
holds descriptor lock / SQLite writer
waits for cs_wallet
Scheduler thread:
holds cs_wallet
waits for SQLite writer
Suggested direction
- Do not emit
NotifyCanGetAddressesChangedwhile holding the descriptor mutex or an active wallet database transaction. - Consider making the Qt notification bridge explicitly queued as additional protection against synchronous GUI re-entry.
- Avoid performing the complete deferred initial P2MR keypool top-up synchronously from the GUI unlock path. It could instead run through bounded scheduler steps.
- Add a regression test that overlaps wallet unlock/deferred top-up with
blockConnected()wallet database activity and asserts both operations complete.
Moving only the signing work off the GUI thread does not address this case because the deadlock happens before transaction preparation starts.
Related issues
- Avoid synchronous P2MR keypool maintenance in getnewaddress #26 addressed synchronous P2MR maintenance in
getnewaddress. - Avoid full synchronous P2MR keypool top-up from MarkUnusedAddresses #14 addressed synchronous P2MR maintenance in
MarkUnusedAddresses.
This appears to be a separate unlock-time path and a concrete descriptor/database/wallet lock cycle.
Activity