nvmd / bitcoin

Bitcoin Core integration/staging tree
https://bitcoin.org/en/download
MIT License
0 stars 0 forks source link

Daemon crashes in InvalidChainFound if genesis block fails validity check #1

Open nvmd opened 9 years ago

nvmd commented 9 years ago

Daemon (0.10 branch, commit 047a89831760ff124740fe9f58411d57ee087078) crashes in InvalidChainFound when run with empty blockchain and genesis block is invalid (fails validity check).

GDB stacktrace:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
CBlockIndex::GetBlockHash (this=0x0) at chain.h:215
215         return *phashBlock;
(gdb) bt
#0  CBlockIndex::GetBlockHash (this=0x0) at chain.h:215
#1  0x0000000100157816 in InvalidChainFound (pindexNew=0x10160d5f0) at main.cpp:1365
#2  0x000000010018106e in InvalidBlockFound (pindex=0x10160d5f0, state=@0x7fff5fbf7a70) at main.cpp:1386
#3  0x000000010017fa12 in ConnectTip (state=@0x7fff5fbf7a70, pindexNew=0x10160d5f0, pblock=0x10085de30) at main.cpp:1989
#4  0x00000001001540d0 in ActivateBestChainStep (state=@0x7fff5fbf7a70, pindexMostWork=0x10160d5f0, pblock=0x10085de30) at main.cpp:2117
#5  0x0000000100152a18 in ActivateBestChain (state=@0x7fff5fbf7a70, pblock=0x10085de30) at main.cpp:2170
#6  0x0000000100163397 in InitBlockIndex () at main.cpp:3098
#7  0x0000000100071b9f in AppInit2 (threadGroup=@0x7fff5fbff688) at init.cpp:1036
#8  0x0000000100005c40 in AppInit (argc=10, argv=0x7fff5fbff898) at bitcoind.cpp:148
#9  0x0000000100005f0a in main (argc=10, argv=0x7fff5fbff898) at bitcoind.cpp:185

main.cpp:1365:

LogPrintf("InvalidChainFound:  current best=%s  height=%d  log2_work=%.8g  date=%s\n",
      chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0),
      DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()));

chainActive.Tip() is NULL, possibly because we don't have an active chain/chain tip as the genesis block verification has just failed.