I'll be of limited help as I tend not to suffer from GI problems and I've also never raced a marathon only ran to complete for social reasons, but I'll offer what I can in the hope that it might help. My 'safe' foods are plain lean meats, rice and sugary drinks.
My last marathon last year I ran the night after a work leaving do where I had a spicy indian curry and got pretty drunk. In the morning I had a bottle of coke a couple of hours out. Despite that crappy prep I had no problems.
The previous year and the only time I ever had an issue was when I was taking it a bit more seriously. I had 6 slices of toast and some oatmeal for breakfast a few hours out. I was gassy as hell and eventually had to stop in a pub somewhere before 20 miles.
My second last marathon last year I was using to make the decision as to whether or not to train for a proper one so was trying to get race prep right. On the advice from Noakes' Lore of Running I avoided dairy and all fibrous foods fairly strictly from about 3 days out. I was trying to 'eat to hunger' with rice/lean meat for main meals and topping up with sugary drinks if I felt the need. Come race morning I really felt like my guts ended up empty, my belly felt flatter and my weight went down slightly despite tapering and eating to hunger.
In the interests of finding your issue it may help to know the basics of digestion if your biology is a bit rusty. Once you've chewed and swallowed your food it first ends up in the stomach, which helps mechanically break down the food and secretes enzymes primarily to assist with protein breakdown. Food is there for a matter of minutes for a sugary drink up to perhaps a couple of hours for a large, fatty or high protein meal. The food then moves into the small intestines which is where the majority of absorption happens. Transit time here is perhaps 4-6 hours, maybe more or less depending on what you ate. Whatever remains then moves into the large intestine where the main job really is reclaiming water. Transit time various largely depending on diet but stuff will pretty much sit there until there is a reason for it to move out.
This is where the interesting bit is and although there is some 'artistic license' in my description it might help you figure out where your problem lies. If your small intestines perceives a threat, like rotten food/bacteria or perhaps an irritant like spicy stuff/caffeine/alcohol/dairy, it might hit the 'emergency dump' button to evacuate and get rid of the threat. You get diarrhea/loose stool because the water content is very high, which is because the crap hasn't spent very long in the large intestine and hence the water hasn't been reclaimed. In a different scenario like where Bad Wigins was talking about fibre, it's the buildup of gas - exacerbated by running - which hits the emergency switch and you may well have normal stool because up until that point the crap has had sufficient time in the large intestine to be dehydrated. You should also have a clue in how farty you are. Very farty obviously suggests a gas induced problem like fibre or dairy. Non farty may suggest a different trigger like caffeine or some other irritant.
What a wonderful topic. I do hope you find your solution!