Crash while keypoolrefill is running #2394

issue Belkaar opened this issue on March 20, 2013
  1. Belkaar commented at 8:48 PM on March 20, 2013: none

    with an encyrpted wallet my client (0.8.1 compiled myself) crashes, if the walletpassphrase timeout occurs before the keypoolrefill has finished. It just closes, no error/crash log messages. The last line in the log is one of these:

    keypool added key 100, size=100

    to reproduce do bitcoind walletpassphrase pass 10 && bitcoind keypoolrefill on a machine with no cpu cycles to spare at the moment

  2. Diapolo commented at 9:20 PM on March 20, 2013: none

    Interesting find, guess no one ever thought about such a corner case then.

  3. simon-liu commented at 9:20 AM on July 16, 2013: none

    I meet the same bug.

    Bitcoin version v0.8.1-beta (2013-03-17 15:35:36 -0400)

  4. luke-jr commented at 5:39 PM on July 16, 2013: member

    FWIW, I also saw this on my 2aa462e-based next-test, after about 800 keys (targetting 10,000 keys). Initially, I assumed it was relayed to the wallet closing timeout, so when I restarted, I put an effectively-infinite timeout on it; it crashed again after about 800 keys. The third try completed successfully. (Obviously next-test isn't going to be a very good report for this kind of bug, but considering others have similar problems I thought it might be useful info to add)

  5. bitnews commented at 1:28 AM on July 17, 2013: none

    After upgrade to v0.8.3-beta, the bug still exists.

  6. simon-liu commented at 2:52 AM on July 17, 2013: none

    I use gdb debug: terminate called after throwing an instance of 'std::runtime_error' what(): CWallet::GenerateNewKey() : AddKey failed

  7. Diapolo commented at 10:54 AM on October 28, 2013: none

    Can you try again with current master?

    I tried keypoolrefill 10000 and used walletpassphrase pass 10, which resulted in:

    Output in debug window - RPC console (Bitcoin-Qt):

    <pre> 11:52:32 keypoolrefill 10000 11:52:34 CWallet::GenerateNewKey() : AddKey failed (code -1) </pre>

    No crash for me!

  8. arnuschky commented at 1:01 AM on December 1, 2013: contributor

    I can confirm that this bug still exists on 0.8.5

  9. Diapolo commented at 10:30 AM on January 27, 2014: none

    Is this still a problem with current master?

  10. bobjansen commented at 7:11 AM on June 2, 2014: none

    I have this issue, on Windows with v0.9.1.0-g026a939-beta (64-bit). Luckily dumpprivkey works but it's still annoying. How can I help?

  11. bobjansen commented at 11:57 AM on June 9, 2014: none

    This wallet was on an installation I seldom use and therefore very simple (1 transaction, 1 bitcoin core upgrade). I still have the old wallet, can I help with some diagnostics?

  12. laanwj added the label Wallet on Jun 9, 2014
  13. laanwj commented at 12:07 PM on June 9, 2014: member

    @bobjansen so can you reproduce this arbitrarily? how do you do that? does it depend on the specific wallet?

  14. bobjansen commented at 7:33 PM on June 9, 2014: none

    @laanwj It seems to depend on this specific wallet. I'm not sure how it got in this state. This is what happens when I use the faulty wallet:

    1. Put it in AppData/Roaming/Bitcoin
    2. Start the GUI
    3. Wait for it to sync
    4. Select the Receive tab
    5. Request a payment
    6. This happens:

    screenshot 2014-06-09 21 17 14 Alternatively, I can do steps 1 to 3 and run keypoolrefill 100 from the console. This gives an error but at least doesn't crash:

    screenshot 2014-06-09 21 21 13

    Closing also gives the same problem and an extra error message which might be useful:

    screenshot 2014-06-09 21 28 51

    Something to note: the wallet is not encrypted. As this wallet was only used for this one transaction and I could move the coins elsewhere using my wallet created from the privkey. Therefore I can safely publish the broken wallet for analysis if so desired.

  15. laanwj commented at 3:33 PM on February 9, 2016: member

    Thanks for the offer, but I don't have time to dive deep into berkeleydb specifics.

    For anyone else coming to this issue, what may work is to run with the option -salvagewallet. This dumps the underlying database structure and rebuilds the wallet. Do make sure that you back up your wallet first, as with any every recovery tool) it may make things worse as well.

  16. laanwj closed this on Feb 9, 2016

  17. 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-21 15:15 UTC

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