You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Review finding: DelAddressBook takes the database writer before cs_wallet #293
CWallet::DelAddressBook opens a database transaction, which takes the database writer, before it locks cs_wallet. The wallet's lock order is cs_wallet -> cs_desc_man -> writer, documented with #277. Any thread that holds cs_wallet and then writes waits for the writer, so the two can deadlock.
Observed
At 1.x.xb27130a7b9, found by reading the code during review of the #285 and #283 fixes. Not reproduced.
DelAddressBook (src/wallet/wallet.cpp:3351-3356) runs RunWithinTxn, whose TxnBegin takes the SQLite writer semaphore. It then calls DelAddressBookWithDB, which takes LOCK(cs_wallet) (:3362) and calls IsMine, which takes cs_desc_man.
The GUI calls it without holding cs_wallet (interfaces::Wallet::delAddressBook).
Many paths hold cs_wallet and then write: EncryptWallet's transaction, AddToWallet when a transaction arrives, and others. A write outside a transaction also takes the writer for each statement.
DEBUG_LOCKORDER cannot detect this, because the writer is a semaphore, not a mutex.
Impact
Low. It needs a GUI address-book deletion to land in the short window between TxnBegin and LOCK(cs_wallet) while another thread holds cs_wallet and writes. The result is a hung wallet. Bitcoin Core v30.2 has the same code.
Suggested fix
Take cs_wallet before starting the transaction in DelAddressBook, to match the documented order. Check the other RunWithinTxn callers for the same shape.
Fixed on 1.x.x by #300 (ea571b86f5), which ships in v1.0.1: DelAddressBook now takes cs_wallet before its database transaction, in the documented order cs_wallet → cs_desc_man → writer.
Closing by hand, because a merge into 1.x.x does not close issues automatically.
Activity
doc: correct the v1.0.1 release notes from the launch review
doc: correct the v1.0.1 release notes from the launch review
kiwidream commentedon Nov 11, 2026
Fixed on
1.x.xby #300 (ea571b86f5), which ships in v1.0.1:DelAddressBooknow takescs_walletbefore its database transaction, in the documented ordercs_wallet→cs_desc_man→ writer.Closing by hand, because a merge into
1.x.xdoes not close issues automatically.doc: correct the v1.0.1 release notes from the launch review
release: prepare v1.0.1 (#181)
release: prepare v1.0.1 (#181)