   Wired runtime error (c0000374)
  Hi people who can may help me.No matter what I do, sometimes it always happens:Critical error detected c0000374Windows has triggered a breakpoint in SimpleFractal.exe.This may be due to a corruption of the heap, which indicates a bug in SimpleFractal.exe or any of the DLLs it has loaded.This may also be due to the user pressing F12 while SimpleFractal.exe has focus.The output window may have more diagnostic information.This is really annoying, it is just a test program (Not my main project, huh), but, well since it's a test program, I want to test something, and not to see it crashing all the time. :( It seems to happen here:void InsertAt(int Where, float value){vector<float>::iterator it=SubD.begin();SubD.insert(it+(Where),value);}//Creates a new Hill with the specified resolutionvoid CreateHill(UINT Res,float StartHeight, float HeightMult=0.1, float Falloff=0.5){////////////////////////////////////// Somewhere in this function! /////////////////////////////////////////SubD.clear();//Start with a simple lineSubD.push_back(0);SubD.push_back(0);float Height=StartHeight;for(int r=0;r<Res;r++){int size=SubD.size();for(int i=0;i<size;i++){//Get the middle of the two pointsfloat mid = (SubD+SubD[i+1])/2;//Apply a small offsetmid+=RandFloat(-Height,Height)*HeightMult;Height*=Falloff; //and the falloff//insert a pointInsertAt(i,mid);//We added an item to the list, increment i by 1i++;}}}Why don't I debug simply? Because sometimes I can hit the recompute buttons thousands of times, without any crash, so it happens randomly. :( I Hate such errors :(EDIT: The Call Stack says, I am here: ntdll.dll!771ddc8d()   
  float mid = (SubD+SubD[i+1])/2;What happens when you are at the last element?Also, the i++, do you need that since you calculate the size of the vector before the for loop.;  Okay, the function is NOT the problem. (It is still very WIP, anyways)I just got that crash while I was just watching the screen... And now what??   ;  It's possible you have multiple bugs, because the problem RabidDog mentions is indeed an issue in your posted code.If you can catch the bug again, try posting the complete call stack rather than just the top.   ;  Hm. Could be that I have multiple bugs in there. I got a crash where I increased detail, and I had a "better" crash location, so I think this is one I can fix myself. But there are also those wired ones, which happen just sometimes, without any action of me. Here is a screenshot of my VC++ after that thing happened:I hope that helps you to help me :)   ;  It's a breakpoint, can you step out of it?If, as it suggests, you are overwriting the heap somewhere, it could have trashed anything.   ;  Wow, yes! Just a press of F5 (Or the play button :P) brings me back to the program! But what does this tell us, and how to disable it?   ;  Well, it tells you nothing now :)Next time hit shift+f11 until you get back to your program, to the line that caused it.Or the step out icon if your keys are setup different to mine.   ;  I can't get back to my code from there. When I am in the file dbgheap.c, it gives me just another exception, and stays in that file...   ;  Chances are it's inside a free or delete that it dies then.Most common cause, you've allocated something and written outside of the space you've allocated.Do you get a better callstack when it is in dbgheap.c ?   