Segfault on shutdown after pressing 'q' to postpone utxo db upgrade #10861

issue sdaftuar opened this issue on July 18, 2017
  1. sdaftuar commented at 12:01 PM on July 18, 2017: member

    Running current master, 7b6e8bc4424006119dc537699c8b3b3121e0b3c3

    I am seeing a segfault on shutdown when I press 'q' in bitcoin-qt to interrupt the utxo database upgrade to being per-txout.

    It looks like it happens in FlushStateToDisk, because pcoinsTip is NULL.

    (lldb) bt
    * thread [#11](/bitcoin-bitcoin/11/), name = 'bitcoin-shutoff', stop reason = EXC_BAD_ACCESS (code=1, address=0x38)
        frame [#0](/bitcoin-bitcoin/0/): 0x00000001003efc06 bitcoin-qt`CCoinsViewCache::DynamicMemoryUsage() const [inlined] std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<COutPoint, CCoinsCacheEntry>, void*>*>*> >::size() const at __hash_table:807 [opt]
        frame [#1](/bitcoin-bitcoin/1/): 0x00000001003efc06 bitcoin-qt`CCoinsViewCache::DynamicMemoryUsage() const [inlined] std::__1::__hash_table<std::__1::__hash_value_type<COutPoint, CCoinsCacheEntry>, std::__1::__unordered_map_hasher<COutPoint, std::__1::__hash_value_type<COutPoint, CCoinsCacheEntry>, SaltedOutpointHasher, false>, std::__1::__unordered_map_equal<COutPoint, std::__1::__hash_value_type<COutPoint, CCoinsCacheEntry>, std::__1::equal_to<COutPoint>, true>, std::__1::allocator<std::__1::__hash_value_type<COutPoint, CCoinsCacheEntry> > >::bucket_count() const at __hash_table:1122 [opt]
        frame [#2](/bitcoin-bitcoin/2/): 0x00000001003efc06 bitcoin-qt`CCoinsViewCache::DynamicMemoryUsage() const [inlined] std::__1::unordered_map<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher, std::__1::equal_to<COutPoint>, std::__1::allocator<std::__1::pair<COutPoint const, CCoinsCacheEntry> > >::bucket_count() const at unordered_map:1140 [opt]
        frame [#3](/bitcoin-bitcoin/3/): 0x00000001003efc06 bitcoin-qt`CCoinsViewCache::DynamicMemoryUsage() const [inlined] unsigned long memusage::DynamicUsage<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher>(std::__1::unordered_map<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher, std::__1::equal_to<COutPoint>, std::__1::allocator<std::__1::pair<COutPoint const, CCoinsCacheEntry> > > const&) at memusage.h:164 [opt]
        frame [#4](/bitcoin-bitcoin/4/): 0x00000001003efc06 bitcoin-qt`CCoinsViewCache::DynamicMemoryUsage(this=0x0000000000000000) const at coins.cpp:40 [opt]
        frame [#5](/bitcoin-bitcoin/5/): 0x00000001002b81b2 bitcoin-qt`FlushStateToDisk(chainparams=<unavailable>, state=0x000070000287a580, mode=<unavailable>, nManualPruneHeight=<unavailable>) at validation.cpp:1899 [opt]
        frame [#6](/bitcoin-bitcoin/6/): 0x00000001002b7960 bitcoin-qt`FlushStateToDisk() at validation.cpp:1969 [opt]
        frame [#7](/bitcoin-bitcoin/7/): 0x000000010014a015 bitcoin-qt`Shutdown() at init.cpp:219 [opt]
      * frame [#8](/bitcoin-bitcoin/8/): 0x00000001000086b1 bitcoin-qt`BitcoinCore::shutdown(this=0x000000010faf9080) at bitcoin.cpp:319 [opt]
        frame [#9](/bitcoin-bitcoin/9/): 0x0000000101f628e1 QtCore`QObject::event(QEvent*) + 801
        frame [#10](/bitcoin-bitcoin/10/): 0x00000001010e588d QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 301
        frame [#11](/bitcoin-bitcoin/11/): 0x00000001010e6c31 QtWidgets`QApplication::notify(QObject*, QEvent*) + 369
        frame [#12](/bitcoin-bitcoin/12/): 0x0000000101f38e54 QtCore`QCoreApplication::notifyInternal2(QObject*, QEvent*) + 164
        frame [#13](/bitcoin-bitcoin/13/): 0x0000000101f39e7b QtCore`QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 891
        frame [#14](/bitcoin-bitcoin/14/): 0x0000000101f8bbb9 QtCore`QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 73
        frame [#15](/bitcoin-bitcoin/15/): 0x0000000101f35171 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 417
        frame [#16](/bitcoin-bitcoin/16/): 0x0000000101d774e3 QtCore`QThread::exec() + 115
        frame [#17](/bitcoin-bitcoin/17/): 0x0000000101d7aeea QtCore`QThreadPrivate::start(void*) + 362
        frame [#18](/bitcoin-bitcoin/18/): 0x00007fffc3210aab libsystem_pthread.dylib`_pthread_body + 180
        frame [#19](/bitcoin-bitcoin/19/): 0x00007fffc32109f7 libsystem_pthread.dylib`_pthread_start + 286
        frame [#20](/bitcoin-bitcoin/20/): 0x00007fffc32101fd libsystem_pthread.dylib`thread_start + 13
    (lldb) 
    
    (lldb) f 5
    frame [#5](/bitcoin-bitcoin/5/): 0x00000001002b81b2 bitcoin-qt`FlushStateToDisk(chainparams=<unavailable>, state=0x000070000287a580, mode=<unavailable>, nManualPruneHeight=<unavailable>) at validation.cpp:1899 [opt]
       1896	        nLastSetChain = nNow;
       1897	    }
       1898	    int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
    -> 1899	    int64_t cacheSize = pcoinsTip->DynamicMemoryUsage();
       1900	    int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0);
       1901	    // The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
       1902	    bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE * 1024 * 1024);
    (lldb) print pcoinsTip
    (CCoinsViewCache *) $1 = 0x0000000000000000
    
  2. jonasschnelli commented at 12:05 PM on July 18, 2017: contributor

    Thanks for the report. Working on a fix.

  3. sipa commented at 12:25 PM on July 18, 2017: member

    Is this not fixed by #10758?

  4. sdaftuar commented at 1:23 PM on July 18, 2017: member

    @sipa Thanks, yes that fixes it.

  5. jonasschnelli added the label GUI on Jul 21, 2017
  6. fanquake commented at 8:23 AM on August 9, 2017: member

    Fixed by #10758

  7. fanquake closed this on Aug 9, 2017

  8. DrahtBot 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 18:15 UTC

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