Document validationinterace callback blocking deadlock potential.

pull/13402/head
Matt Corallo 7 years ago
parent a589f536b5
commit 25bc9615b7

@ -2704,6 +2704,9 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
// Block until the validation queue drains. This should largely // Block until the validation queue drains. This should largely
// never happen in normal operation, however may happen during // never happen in normal operation, however may happen during
// reindex, causing memory blowup if we run too far ahead. // reindex, causing memory blowup if we run too far ahead.
// Note that if a validationinterface callback ends up calling
// ActivateBestChain this may lead to a deadlock! We should
// probably have a DEBUG_LOCKORDER test for this in the future.
SyncWithValidationInterfaceQueue(); SyncWithValidationInterfaceQueue();
} }

@ -233,7 +233,8 @@ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
* Note that we guarantee that either the proof-of-work is valid on pblock, or * Note that we guarantee that either the proof-of-work is valid on pblock, or
* (and possibly also) BlockChecked will have been called. * (and possibly also) BlockChecked will have been called.
* *
* Call without cs_main held. * May not be called with cs_main held. May not be called in a
* validationinterface callback.
* *
* @param[in] pblock The block we want to process. * @param[in] pblock The block we want to process.
* @param[in] fForceProcessing Process this block even if unrequested; used for non-network block sources and whitelisted peers. * @param[in] fForceProcessing Process this block even if unrequested; used for non-network block sources and whitelisted peers.
@ -245,7 +246,8 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons
/** /**
* Process incoming block headers. * Process incoming block headers.
* *
* Call without cs_main held. * May not be called with cs_main held. May not be called in a
* validationinterface callback.
* *
* @param[in] block The block headers themselves * @param[in] block The block headers themselves
* @param[out] state This may be set to an Error state if any error occurred processing them * @param[out] state This may be set to an Error state if any error occurred processing them
@ -278,7 +280,12 @@ void ThreadScriptCheck();
bool IsInitialBlockDownload(); bool IsInitialBlockDownload();
/** Retrieve a transaction (from memory pool, or from disk, if possible) */ /** Retrieve a transaction (from memory pool, or from disk, if possible) */
bool GetTransaction(const uint256& hash, CTransactionRef& tx, const Consensus::Params& params, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr); bool GetTransaction(const uint256& hash, CTransactionRef& tx, const Consensus::Params& params, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr);
/** Find the best known block, and make it the tip of the block chain */ /**
* Find the best known block, and make it the tip of the block chain
*
* May not be called with cs_main held. May not be called in a
* validationinterface callback.
*/
bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>()); bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>());
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
@ -445,7 +452,11 @@ inline CBlockIndex* LookupBlockIndex(const uint256& hash)
/** Find the last common block between the parameter chain and a locator. */ /** Find the last common block between the parameter chain and a locator. */
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator); CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator);
/** Mark a block as precious and reorganize. */ /** Mark a block as precious and reorganize.
*
* May not be called with cs_main held. May not be called in a
* validationinterface callback.
*/
bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex); bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex);
/** Mark a block as invalid. */ /** Mark a block as invalid. */

Loading…
Cancel
Save