Encrypted wallets and -salvagewallet #2480

issue laanwj opened this issue on April 7, 2013
  1. laanwj commented at 8:04 AM on April 7, 2013: member

    Salvaging an encrypted wallet makes bitcoin quit with the following error:

    bitcoin-qt: /usr/include/boost/thread/pthread/pthread_mutex_scoped_lock.hpp:26: boost::pthread::pthread_mutex_scoped_lock::pthread_mutex_scoped_lock(pthread_mutex_t*): Assertion `!pthread_mutex_lock(m)' failed.
    Aborted (core dumped)
    

    Steps to reproduce:

    1. Create new testnet wallet
    2. Encrypt with a passphrase
    3. Run with -salvagewallet

    debug.log:

    init message: Verifying wallet...
    dbenv.open LogDir=/home/.../.bitcoin/testnet3/database ErrorFile=/home/.../.bitcoin/testnet3/db.log
    Renamed wallet.dat to wallet.1365321353.bak
    Salvage(aggressive) found 317 records
    Bound to [::]:18333
    Bound to 0.0.0.0:18333
    init message: Loading block index...
    Opening LevelDB in /home/.../.bitcoin/testnet3/blocks/index
    Opened LevelDB successfully
    Opening LevelDB in /home/.../.bitcoin/testnet3/chainstate
    Opened LevelDB successfully
    LoadBlockIndexDB(): last block file = 0
    LoadBlockIndexDB(): last block file info: CBlockFileInfo(blocks=65142, size=47761205, heights=0...65141, time=2011-02-02...2013-04-07)
    LoadBlockIndexDB(): transaction index disabled
    LoadBlockIndexDB(): hashBestChain=000000000a00a2818dd027f323048e7e0b273a3cd0511b0ad129166d9d5d45a2  height=65141 date=2013-04-07 07:46:02
    init message: Verifying blocks...
    Verifying last 288 blocks at level 3
    No coin database inconsistencies in last 289 blocks (3282 transactions)
     block index            1377ms
    init message: Loading wallet...
    nFileVersion = 80000
    Performing wallet upgrade to 60000
    Cannot initialize keypool
    

    The keypool error appears every time at startup, from then on. The wallet may be corrupted, but it from the error appears to be a bug in the code with mutexes.

  2. ghost commented at 3:34 PM on April 16, 2013: none

    This is your fix. You can't trail like that in Boost(yet): http://stackoverflow.com/questions/11505811/creating-a-separate-boost-thread-for-endpoint-listen-in-a-multithreaded-progra

    Sorry i'm not at my workstation to test but I have had that issue before and those directions fixed it

  3. sipa commented at 6:03 PM on April 25, 2013: member

    There are two issues here. The first is the reported problem (-salvagewallet not working with encrypted wallets due the the keypool initialization failing, see #2566 for a fix). The other seems a problem with exceptional exits in combination with Gavin's thread rewrite in Bitcoin-Qt.

  4. gavinandresen commented at 4:11 PM on May 2, 2013: contributor

    I'm testing a fix for the second issue; it is being caused by destructors being called after main() exits.

  5. gavinandresen referenced this in commit d605bc4cd1 on May 2, 2013
  6. sipa referenced this in commit abe3c6c22e on May 2, 2013
  7. laanwj commented at 9:46 PM on May 3, 2013: member

    Can confirm that this is solved by #2566

  8. laanwj closed this on May 3, 2013

  9. ryepdx commented at 11:59 PM on May 6, 2013: none

    Sipa, you have 0.010945 BTC waiting for you on bitcoinbounties.com. Please login with your Github account and provide a payout Bitcoin address so we can send it to you.

    Thanks! :-)

  10. sipa commented at 12:30 AM on May 7, 2013: member

    @ryepdx Great, but the "Complete registration" button after entering my address doesn't really seem to do anything...

  11. ryepdx commented at 1:21 AM on May 7, 2013: none

    Hmm, okay. What browser are you in? Can you email me at (redacted)? I don't want to spam up this issue page.

    EDIT: Looks like Github started requiring a User-Agent string in their API calls. Updated the Github API library I was using and everything seems to be working now. How does it look on your end?

  12. kyledrake referenced this in commit f8355f87b1 on Jul 25, 2013
  13. laudney referenced this in commit cb4016806b on Mar 19, 2014
  14. webwakko commented at 12:17 PM on December 7, 2017: none

    How can you open a *.bak file created by --salvagewallet?

  15. MarcoFalke 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 15:16 UTC

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