Exception: St11logic_error - Not all cached coins were erased - bitcoin in Runaway exception #29556

issue bitcoin-pow opened this issue on March 4, 2024
  1. bitcoin-pow commented at 6:11 PM on March 4, 2024: none

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    I have merged the Bitcoin PoW/PoT code into the BTC 26x baseline. After 8 hours of running I generally see the error:


    Exception: St11logic_error Not all cached coins were erased bitcoin in Runaway exception

    The code was posted here: https://github.com/bitcoin/bitcoin/pull/29455/

    Not sure why the title was deleted...

    BitcoinPoW (BTCW) is a modified version of Bitcoin. It uses proof of transactions as a way to perform work. This means that each wallet on the BTCW network generally has between 20,000 and 100,000 utxos and the txids of those utxos are used in the hashing.

    The exception points to the Pool code here: https://github.com/bitcoin/bitcoin/blob/26.x/src/support/allocators/pool.h

    I have not debugged in detail the issue, but seems that there is a possible bug in the pool.h code that hasn't surfaced because of low utxo counts in BTC wallets.

    It should also be noted that:

    using CCoinsMap = std::unordered_map<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher, std::equal_to<COutPoint>, PoolAllocator<std::pair<const COutPoint, CCoinsCacheEntry>, sizeof(std::pair<const COutPoint, CCoinsCacheEntry>) + sizeof(void*) * 4>>;

    Is new as of 26.x. Previous version of BTCW was using 21.x baseline and never encountered this issue. 25.x and earlier baselines never used the PoolAllocator for the CCoinsMap.

    Turns out that if I comment out all the custom Pool Alloc/Dealloc code and only use new/delete as shown below, the problem goes away. This points to the below possibllities.

    A) multi threading issues within these methods. - new/delete is thread safe, but the custom code is not. B) byte alignment issues, using 4 different variations of paths: -Allocate/Deallocate -Allocate/delete -new/Deallocate -new/delete -> this is safe and the issue is not present.

    Have there been test cases to cover the 4 paths above?

    /// NOTE: This code fixes the issue. void* Allocate(std::size_t bytes, std::size_t alignment) { // Can't use the pool => use operator new() return ::operator new (bytes, std::align_val_t{alignment}); }

    void Deallocate(void* p, std::size_t bytes, std::size_t alignment) noexcept
    {
            // Can't use the pool => forward deallocation to ::operator delete().
            ::operator delete (p, std::align_val_t{alignment});
    }

    Expected behaviour

    Exception should not be thrown.

    Steps to reproduce

    Modify the 26.x baseline with BTCW code here: https://github.com/bitcoin/bitcoin/pull/29455/

    and mine on the BTCW network with 50,000 utxos.

    Relevant log output


    Exception: Stlllogic_error Not all cached coins were erased bitcoin in Runaway exception

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    https://github.com/bitcoin/bitcoin/commit/74df372750ceb4ccdfe310e18f14cdd3abac4a51

    Operating system and version

    Ubuntu 20 and 22

    Machine specifications

    No response

  2. bitcoin-pow renamed this:
    Exception: Stlllogic_error - Not all cached coins were erased - bitcoin in Runaway exception
    Exception: St11logic_error - Not all cached coins were erased - bitcoin in Runaway exception
    on Mar 4, 2024
  3. bitcoin-pow commented at 7:14 PM on March 4, 2024: none

    Turns out issue is still there, just takes much longer to surface with update, I'll need to deep dive. Closing this for now.

  4. bitcoin-pow closed this on Mar 4, 2024

  5. bitcoin locked this on Mar 4, 2024
Contributors

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-05-01 15:13 UTC

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