Save n, Windows 7. Hit end turn. Patiently wait. Game crashes.
Darrell
The AI is casting a spell which causes war. Since they are either in enemy territory or sharing a plot with enemy units this cause all the units in the stack to be moved away. In doing so they leave the old group and join a new one (with just one unit per group). Why does this cause a crash? Because the old group is now empty and should be removed but it's not. Then we call something for the head unit, which doesn't exist, and we get a crash.
Coding stuff
In
all places where you/AI can cast spells there has to be sanity checks for if the unit/group is dead. In this case it's in CvSelectionGroup::groupAttack. It's actually really stupid of the AI to cast the spell in this case, since they're about to attack a city and instead get all their units moved plus a new war to deal with. It's really stupid of the AI to so easily declare war in the first place simply because there's a lot more enemy units nearby than non-enemy units.
The lines I don't like are these in CvUnitAI::AI_DirectDamageCast
Assuming no same team units, if we can damage 100/iDmg enemies we don't care that we declare war, because we're doing so much damage. If we're casting say maelstrom, that means we'll declare war if there's seven enemies per non-enemy unit! Regardless of who we declare war on!
Enough complaining about poor AI

To solve the bug, after _every_ spellcasting attempt, check if the group is dead. If you do not do it after every spell attempt the behavior can be unpredictable. I saw some units cast spells that were no longer even part of the group, before the CtD.
In CvSelectionGroup::groupAttack
pLoopUnit->AI_DirectDamageCast(5);
if (doDelayedDeath())
{
return false;
}
This does cause an FAssert (later on trying to remove the group after it's already removed) but I don't think it'll cause any actual bugs.
The same code after the other three spellcasts. And after any other spellcasts anywhere else in the code.