This is a well known (long standing) issue. Documented in the code base in commit eea02be70ee37b845f2719b3c08e5baf4b6f51f6.

Countless intermittent sanitizer warnings can be attributed to it.
RandAddEvent((uint32_t)id);
}
void CConnman::DisconnectNodes()
{
    {
        LOCK(cs_vNodes);
        if (!fNetworkActive) {
            
            for (CNode* pnode : vNodes) {
                if (!pnode->fDisconnect) {
                    LogPrint(BCLog::NET, "Network not active, dropping peer=%d\n", pnode->GetId());
                    pnode->fDisconnect = true;
                }
            }
        }
        
        std::vector<CNode*> vNodesCopy = vNodes;
        for (CNode* pnode : vNodesCopy)
        {
            if (pnode->fDisconnect)
            {
                
                vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());
                
                pnode->grantOutbound.Release();
                
                pnode->CloseSocketDisconnect();
                
                pnode->Release();