loadwallet command crashes bitcoind #14538

issue chernyshev openend this issue on October 21, 2018
  1. chernyshev commented at 6:54 pm on October 21, 2018: none

    bitcoin-cli loadwallet "wallet.dat" command causes bitcoind crash

    log info:

    0bitcoind: wallet/db.cpp:236: BerkeleyEnvironment::VerifyResult BerkeleyEnvironment::Verify(const string&, BerkeleyEnvironment::recoverFunc_type, std::__cxx11::string&): Assertion `mapFileUseCount.count(strFile) == 0' failed.
    1Aborted (core dumped)
    

    Bitcoin Core Daemon version v0.17.0.0-ge1ed37edaedc85b8c3468bd9a726046344036243

  2. promag commented at 7:30 pm on October 21, 2018: member
    I confirm the crash.
  3. MarcoFalke added the label Wallet on Oct 21, 2018
  4. ken2812221 commented at 2:56 am on October 22, 2018: contributor
    @promag I assume this is broken duplicate fileid detection, so #14320 might fix the issue. Nope. It still exist on master.
  5. ryanofsky commented at 7:23 pm on October 23, 2018: member

    Fix from ken2812221 looks right, but I would want to tweak it a bit so wallet.dat is handled at the database layer. I’ll post a suggestion in #14552.

    This issue was really confusing to debug. We have two different checks to prevent opening the same wallet multiple times, and this is slipping between the two checks. The more general check is in CheckUniqueFileid:

    https://github.com/bitcoin/bitcoin/blob/b3f377daaa86cd7755a552fa3adfeb195835f58e/src/wallet/db.cpp#L506-L508

    but because it runs lazily, it is skipped if the btree path is already open:

    https://github.com/bitcoin/bitcoin/blob/b3f377daaa86cd7755a552fa3adfeb195835f58e/src/wallet/db.cpp#L467

    We have a different check in CWallet::Verify which checks for duplicate paths:

    https://github.com/bitcoin/bitcoin/blob/b3f377daaa86cd7755a552fa3adfeb195835f58e/src/wallet/wallet.cpp#L3846

    But it is somewhat broken and #14552 fixes it. The actual crash (at least the crash triggered by the test in #14552) happens in an assert here:

    https://github.com/bitcoin/bitcoin/blob/b3f377daaa86cd7755a552fa3adfeb195835f58e/src/wallet/db.cpp#L236

  6. furqansiddiqui commented at 11:14 am on October 25, 2018: none

    this is becoming real problem for me as well, the daemon crashes without any trace, here is what debug.log file has to say about this:

    2018-10-25T11:05:28Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010) 2018-10-25T11:05:28Z Using wallet wallet.dat 2018-10-25T11:05:28Z init message: Loading wallet… 2018-10-25T11:05:28Z [62055ff271e502760352b420d4f9b39e015ee2c4] nFileVersion = 170000 2018-10-25T11:05:28Z [62055ff271e502760352b420d4f9b39e015ee2c4] Keys: 0 plaintext, 4035 encrypted, 4035 w/ metadata, 4035 total. Unknown wallet records: 1 2018-10-25T11:05:28Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010) 2018-10-25T11:05:28Z Using wallet wallet.dat

    Even though it says Using BerkelyDB… etc.. in final 2 lines but in fact daemon is already crashed

    p.s. “62055f….” is name of a wallet

  7. ryanofsky commented at 11:38 am on October 25, 2018: member

    @furqansiddiqui are you sure this is the same issue? The crash reported here happens when loading the same wallet file twice. There is a flaw in the check for already-loaded wallets that sometimes allows an already opened wallet to be partially reopened, resulting in a crash instead of a clean error message.

    If the crash you’re seeing is not a result of trying to load a wallet that is already loaded, it would be helpful if you could create a new github issue and describe your configuration and command lines so we can attempt to debug it.

  8. furqansiddiqui commented at 11:45 am on October 25, 2018: none

    Actually in my implementation a wallet is dynamically loaded at start of HTTP request and released/unloaded as it ends, this issue arises when a user repeatedly refreshes (actually just hitting F5 few times within a second) therefore I am sure its related to loading a wallet that is already loaded or in process of being loaded at node. I will of course do some fix from my end but I firmly believe this needs to be resolved and at very least need to have proper crash log so I can perhaps able to modify flow on my end

    On Thu, Oct 25, 2018 at 4:40 PM Russell Yanofsky notifications@github.com wrote:

    @furqansiddiqui https://github.com/furqansiddiqui are you sure this is the same issue? The crash reported here happens when loading the same wallet file twice. There is a flaw in the check for already-loaded wallets that sometimes allows an already opened wallet to be partially reopened, resulting in a crash instead of a clean error message.

    If the crash you’re seeing is not a result of trying to load a wallet that is already loaded, it would be helpful if you could create a new github issue and describe your configuration and command lines so we can attempt to debug it.

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/issues/14538#issuecomment-433017551, or mute the thread https://github.com/notifications/unsubscribe-auth/AK9ABfjBL094WMDPdjrsJFKN4S8v6iCdks5uoaMTgaJpZM4XynCo .

    – Regards, Mfurqan Sid.

    Cell: +923212275432

  9. promag commented at 11:50 am on October 25, 2018: member
  10. furqansiddiqui commented at 11:54 am on October 25, 2018: none

    Okay but it is guaranteed that wallet is unloaded when we see releasing wallet message in log?

    I am sure a solution to this issue will also resolve mine

    On Thu, Oct 25, 2018, 4:52 PM João Barbosa notifications@github.com wrote:

    @furqansiddiqui https://github.com/furqansiddiqui it is not guaranteed that the wallet is unloaded when the unloadwallet RPC returns.

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/issues/14538#issuecomment-433020643, or mute the thread https://github.com/notifications/unsubscribe-auth/AK9ABW-8dKW3h23w32wvJn5WSjlbDRfpks5uoaXigaJpZM4XynCo .

  11. promag commented at 11:55 am on October 25, 2018: member

    Okay but it is guaranteed that wallet is unloaded when we see releasing wallet message in log?

    Yes. I’m not sure what your problem is but as @ryanofsky said, better open a new issue since the original issue here is fixed by #14552.

  12. ryanofsky commented at 12:02 pm on October 25, 2018: member

    @furqansiddiqui, if you are able to build master, I think it is likely #14320 fixes your problem, and if it doesn’t I would definitely encourage you to report a new issue with information about your configuration.

    From what you are describing, the issue reported here is not directly related and #14552 will not fix it. The issue reported here is about a crash that happens when attempting to load the same wallet with different path strings, and a flaw in bitcoind where it assumes the paths refer to different wallets and tries to load both.

    It sounds like if someone is hitting F5 repeatedly on your site it will attempt to load the same wallet with the same path string. If this is causing crashes and #14320 doesn’t fix it, this is something we will need to fix separately, so I’d encourage you to file an issue and maybe test #14320.

  13. promag commented at 12:46 pm on October 25, 2018: member
    @ryanofsky thanks for the correction.
  14. furqansiddiqui commented at 12:50 pm on October 25, 2018: none

    I am getting following error when running make command after checking out master and pulling latest commits

    make[3]: Leaving directory ‘/root/bitcoin’ CXX wallet/libbitcoin_wallet_a-walletutil.o wallet/walletutil.cpp: In function ‘std::vectorboost::filesystem::path ListWalletDir()’: wallet/walletutil.cpp:60:32: error: ‘relative’ is not a member of ‘fs’ paths.emplace_back(fs::relative(it->path(), wallet_dir)); ^ wallet/walletutil.cpp:71:36: error: ‘relative’ is not a member of ‘fs’ paths.emplace_back(fs::relative(it->path(), wallet_dir)); ^ Makefile:6911: recipe for target ‘wallet/libbitcoin_wallet_a-walletutil.o’ failed make[2]: *** [wallet/libbitcoin_wallet_a-walletutil.o] Error 1 make[2]: Leaving directory ‘/root/bitcoin/src’ Makefile:10249: recipe for target ‘all-recursive’ failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory ‘/root/bitcoin/src’ Makefile:774: recipe for target ‘all

  15. promag commented at 12:51 pm on October 25, 2018: member
    @furqansiddiqui either use most recent boost or change to #14561 branch instead of master.
  16. furqansiddiqui commented at 1:43 pm on October 25, 2018: none

    @furqansiddiqui, if you are able to build master, I think it is likely #14320 fixes your problem, and if it doesn’t I would definitely encourage you to report a new issue with information about your configuration.

    From what you are describing, the issue reported here is not directly related and #14552 will not fix it. The issue reported here is about a crash that happens when attempting to load the same wallet with different path strings, and a flaw in bitcoind where it assumes the paths refer to different wallets and tries to load both.

    It sounds like if someone is hitting F5 repeatedly on your site it will attempt to load the same wallet with the same path string. If this is causing crashes and #14320 doesn’t fix it, this is something we will need to fix separately, so I’d encourage you to file an issue and maybe test #14320.

    @furqansiddiqui either use most recent boost or change to #14561 branch instead of master.

    changed to #14561 branch, tried but no it doesn’t fix my issue, I will open new issue then

  17. laanwj closed this on Nov 20, 2018

  18. laanwj referenced this in commit afa506f6eb on Nov 20, 2018
  19. xdustinface referenced this in commit 3ab52117af on Apr 4, 2021
  20. xdustinface referenced this in commit 96cec4daac on Apr 4, 2021
  21. xdustinface referenced this in commit 39287dff5b on Apr 4, 2021
  22. xdustinface referenced this in commit 5b1213bf66 on Apr 4, 2021
  23. xdustinface referenced this in commit 5db88d27cb on Apr 5, 2021
  24. xdustinface referenced this in commit 6246ba9181 on Apr 13, 2021
  25. DrahtBot locked this on Sep 8, 2021
  26. gades referenced this in commit a42107b604 on Mar 22, 2022

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: 2024-11-17 12:12 UTC

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