LoadChainTip requires cs_main to be locked. Under some conditions, it may call ActivateBestChain. However, ActivateBestChain requires cs_main NOT to be taken when called.
EraseBlockData(tip);
            tip = tip->pprev;
        }
        
        LimitValidationInterfaceQueue();
        
        if (!FlushStateToDisk(params, state, FlushStateMode::PERIODIC)) {
            LogPrintf("RewindBlockIndex: unable to flush state to disk (%s)\n", FormatStateMessage(state));
            return false;
        }
    }
    {
        LOCK(cs_main);
        if (m_chain.Tip() != nullptr) {
            
            
            PruneBlockIndexCandidates();
            CheckBlockIndex(params.GetConsensus());
        }
    }
    return true;
}
bool RewindBlockIndex(const CChainParams& params) {