I suffer from one or two each xc season during races. Most of the causes that I've heard have been two sided. i.e. too much/not enough: water, oxygen, etc.
From the sound of it, they usually hit you later in the race. I tend to get mine when I lose track of my breathing—often later in the race when I've needed to push the pace midway through. Focusing on your breathing can help you get rid of it mid race. I've read that exhaling with gusto stretches the abdomen while your breaths fall into rhythm.
I tend to think that having a strong core also helps prevent them. Not sure if core work helps directly or indirectly.