Fix deadlocks in getaccountaddress, setaccount, sendfrom RPC calls #143

pull jgarzik wants to merge 2 commits into bitcoin:master from jgarzik:deadlock-fixes changing 4 files +85 −67
  1. jgarzik commented at 2:28 AM on April 5, 2011: contributor

    SendMoney*() now requires caller to acquire cs_main. GetAccountAddress() now requires caller to acquire cs_main, cs_mapWallet.

    Ordering is intended to match these two callchains[1]:

    1. CRITICAL_BLOCK(cs_main) ProcessMessage(pfrom, strCommand, vMsg) AddToWalletIfMine() AddToWallet(wtx) CRITICAL_BLOCK(cs_mapWallet)
    2. CRITICAL_BLOCK(cs_main) ProcessMessage(pfrom, strCommand, vMsg) AddToWalletIfMine() AddToWallet(wtx) CRITICAL_BLOCK(cs_mapWallet) walletdb.WriteName(PubKeyToAddress(vchDefaultKey), "") CRITICAL_BLOCK(cs_mapAddressBook)

    Spotted by ArtForz. Additional deadlock fixes by Gavin.

    [1] http://www.bitcoin.org/smf/index.php?topic=4904.msg71897#msg71897

  2. Fix deadlocks in setaccount, sendfrom RPC calls
    SendMoney*() now requires caller to acquire cs_main.
    GetAccountAddress() now requires caller to acquire cs_main, cs_mapWallet.
    
    Ordering is intended to match these two callchains[1]:
    
    1. CRITICAL_BLOCK(cs_main)
        ProcessMessage(pfrom, strCommand, vMsg)
            AddToWalletIfMine()
                  AddToWallet(wtx)
                      CRITICAL_BLOCK(cs_mapWallet)
    
    2. CRITICAL_BLOCK(cs_main)
        ProcessMessage(pfrom, strCommand, vMsg)
            AddToWalletIfMine()
                  AddToWallet(wtx)
                      CRITICAL_BLOCK(cs_mapWallet)
                          walletdb.WriteName(PubKeyToAddress(vchDefaultKey), "")
                              CRITICAL_BLOCK(cs_mapAddressBook)
    
    Spotted by ArtForz.  Additional deadlock fixes by Gavin.
    
    [1] http://www.bitcoin.org/smf/index.php?topic=4904.msg71897#msg71897
    f5f1878ba1
  3. RPC sendmany must acquire cs_main lock 6f074b71bb
  4. jgarzik commented at 7:16 PM on April 5, 2011: contributor

    Added sendmany fix, spotted by Gavin.

  5. gavinandresen merged this on Apr 5, 2011
  6. gavinandresen closed this on Apr 5, 2011

  7. sipa referenced this in commit ecae2acb06 on Dec 11, 2014
  8. glv2 referenced this in commit 51122f448c on Dec 11, 2014
  9. TheBlueMatt referenced this in commit 582b2934e6 on Oct 20, 2015
  10. kleetus referenced this in commit 803d69203a on Feb 5, 2016
  11. deadalnix referenced this in commit dbdcba1595 on Sep 18, 2016
  12. deadalnix referenced this in commit b43b79a5b1 on Jan 19, 2017
  13. jtimon referenced this in commit 35bdef3ed6 on Apr 20, 2017
  14. destenson referenced this in commit f23e5bb42a on Nov 18, 2017
  15. MarcoFalke referenced this in commit 4d550ffab6 on Jul 30, 2018
  16. 0xartem referenced this in commit d8f7cc8d2b on Sep 5, 2018
  17. 0xartem referenced this in commit a44d133efe on Sep 5, 2018
  18. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me