0.16.0 bitcoin-qt: "Assertion `copyFrom' failed" during launch #13110

issue DeltaLeonis opened this issue on April 28, 2018
  1. DeltaLeonis commented at 7:01 PM on April 28, 2018: none

    <!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->

    <!-- Describe the issue -->

    During startup of bitcoint-qt version 0.16.0

    $ ./bitcoin-qt
    

    the following assertion is triggered:

    bitcoin-qt: wallet/wallet.cpp:542: void CWallet::SyncMetaData(std::pair<std::_Rb_tree_iterator<std::pair<const COutPoint, uint256> >, std::_Rb_tree_iterator<std::pair<const COutPoint, uint256> > >): Assertion `copyFrom' failed.
    

    The issue reliably reproduces with 0.16.0 when using the same ~/.bitcoin directory that was used without problems in 0.15.1. Relaunching 0.15.1 instead of 0.16.0 gives no assertion failure and still works without any issue.

    A (stripped down) debug.log is attached here. The log really ends at 2018-04-28 17:21:47 init message: Loading wallet... (which seems consistent with the assertion failure).

    bitcoin.conf is an empty, zero byte file.

    This machine runs (K)Ubuntu 17.04. CPU is an AMD A6-7400K Radeon R5, 6 Compute Cores 2C+4G. Disk is an Intel 512 GB 545s SSD.

    Bitcoin Core 0.15.1 was downloaded from https://bitcoin.org/bin/bitcoin-core-0.15.1/bitcoin-0.15.1-x86_64-linux-gnu.tar.gz if I recall correctly.

    Bitcoin Core 0.16.0 was downloaded from https://bitcoincore.org/bin/bitcoin-core-0.16.0/bitcoin-0.16.0-x86_64-linux-gnu.tar.gz.

    Note that those are not versions from the Ubuntu repositories/the Ubuntu specific downloads.

    <!--- What behavior did you expect? -->

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    <!--- How reliably can you reproduce the issue, what are the steps to do so? -->

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    <!-- Any extra information that might be useful in the debugging process. -->

    <!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->

  2. laanwj added the label Wallet on Apr 30, 2018
  3. laanwj added the label Bug on Apr 30, 2018
  4. laanwj commented at 12:20 PM on April 30, 2018: member

    Interesting: this assertion was added in #11074. This was indeed first released in 0.16.0.

    Can you try to run with that commit (6c4042a5d0796b732f441669117b909a3247e465) reverted?

    It might segfault later on, I have no idea what can cause copyFrom to be null but apparently the assumption behind adding it was not correct.

  5. MarcoFalke added this to the milestone 0.16.1 on Apr 30, 2018
  6. MarcoFalke commented at 12:43 PM on April 30, 2018: member

    We should probably return early if there is nothing to copy from, i.e. range.first == range.second

  7. DeltaLeonis commented at 6:15 PM on April 30, 2018: none

    Thanks for the response. I will try to (build and) run 0.16.0 with commit 6c4042a5d0796b732f441669117b909a3247e465 reverted but having limited time available at the moment it might take a while before I follow up.

  8. DeltaLeonis commented at 3:12 AM on May 1, 2018: none

    With commit 6c4042a5d0796b732f441669117b909a3247e465 reverted I get:

    bitcoin-qt: wallet/wallet.cpp:547: void CWallet::SyncMetaData(std::pair<std::_Rb_tree_iterator<std::pair<const COutPoint, uint256> >, std::_Rb_tree_iterator<std::pair<const COutPoint, uint256> > >): Assertion `copyFrom && "Oldest wallet transaction in range assumed to have been found."' failed.
    

    I could try with commit fdc329376c8a0fa4dffd0cd2599a494a64c38472 additionally reverted but it seems obvious at this point that it would dereference a NULL pointer at

    if (!copyFrom->IsEquivalentTo(*copyTo)) continue;
    
  9. laanwj commented at 4:00 PM on May 1, 2018: member

    This should work:

    diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
    index 6e0f49f..844167d 100644
    --- a/src/wallet/wallet.cpp
    +++ b/src/wallet/wallet.cpp
    @@ -548,7 +548,9 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
             }
         }
     
    -    assert(copyFrom);
    +    if (!copyFrom) {
    +        return;
    +    }
     
         // Now copy data from copyFrom to rest:
         for (TxSpends::iterator it = range.first; it != range.second; ++it)
    
  10. DeltaLeonis commented at 6:55 AM on May 3, 2018: none

    This does indeed seem to work.

    However, I guess it only fixes the symptom but does not explain why copyFrom is a nullptr for me, yet isn't for most people? (well... that's what I assume).

    I have not tried to understand the code in more detail and/or run with GDB, but can try to do so if we want to understand the cause? Two remarks about this wallet:

    • It only consists of a few old transactions (over 300 000 confirmations) where coins were received
    • No coins were ever spent
    • It's not an HD wallet

    By the way, note that the line

    assert(copyFrom && "Oldest wallet transaction in range assumed to have been found.");
    

    seems superfluous to me anyway (either the assert(copyFrom) or your suggested patch will prevent it from ever failing).

  11. laanwj assigned laanwj on May 17, 2018
  12. laanwj referenced this in commit b0d2ca9fb6 on May 17, 2018
  13. laanwj commented at 8:17 PM on May 17, 2018: member

    I think the explanation is simply that in your case, there is no metadata to sync, so the range is empty.

  14. laanwj closed this on May 18, 2018

  15. laanwj referenced this in commit 1a8b12c69c on May 18, 2018
  16. fanquake referenced this in commit 6c4a1f777e on May 18, 2018
  17. laanwj referenced this in commit 5d8de76257 on May 18, 2018
  18. stamhe referenced this in commit 795937c607 on Jun 27, 2018
  19. HashUnlimited referenced this in commit c474d0166f on Jun 29, 2018
  20. joemphilips referenced this in commit ee3042feb5 on Nov 9, 2018
  21. deadalnix referenced this in commit 61fa035c75 on Mar 5, 2020
  22. PastaPastaPasta referenced this in commit 4617190552 on Mar 14, 2020
  23. ftrader referenced this in commit 41a71b7274 on May 19, 2020
  24. PastaPastaPasta referenced this in commit 9f938eeff9 on Jun 17, 2020
  25. PastaPastaPasta referenced this in commit f41eb6954d on Jun 27, 2020
  26. PastaPastaPasta referenced this in commit 81267ff6ec on Jun 28, 2020
  27. PastaPastaPasta referenced this in commit 5eae39e5ee on Jun 29, 2020
  28. PastaPastaPasta referenced this in commit 18f2393428 on Jul 1, 2020
  29. DrahtBot locked this on Sep 8, 2021
  30. gades referenced this in commit 5d05f86358 on Mar 10, 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: 2026-04-13 18:15 UTC

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