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.
LimitValidationInterfaceQueue();
        {
            LOCK(cs_main);
            CBlockIndex* starting_tip = m_chain.Tip();
            bool blocks_connected = false;
            do {
                
                
                ConnectTrace connectTrace(mempool); 
                if (pindexMostWork == nullptr) {
                    pindexMostWork = FindMostWorkChain();
                }
                
                if (pindexMostWork == nullptr || pindexMostWork == m_chain.Tip()) {
                    break;
                }
                bool fInvalidFound = false;
                std::shared_ptr<const CBlock> nullBlockPtr;
                if (!ActivateBestChainStep(state, chainparams, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : nullBlockPtr, fInvalidFound, connectTrace))
                    return false;
                blocks_connected = true;
                if (fInvalidFound) {
                    
                    pindexMostWork = nullptr;
                }
                pindexNewTip = m_chain.Tip();
                for (const PerBlockConnectTrace& trace : connectTrace.GetBlocksConnected()) {
                    assert(trace.pblock && trace.pindex);
                    GetMainSignals().BlockConnected(trace.pblock, trace.pindex, trace.conflictedTxs);
                }