The problem is you are stepping outside of array bounds somewhere and writing to space you shouldn't be. That is corrupting the heap. (EDIT: so, to clarify, the problem is probably in the [Fill in arr] code you didnt' post /EDIT)
The reason the program is stopping at the delete[] line is because delete[] actually examines the heap and notices that it's been messed up. But that doesn't really tell you where in your code it's actually being messed up.
One approach you can take to try and find the problem:
- find all the code that accesses 'arr'
- start commenting out blocks of it and run until the problem goes away
- once you narrow down which area of code the problem is occuring in, examine it closely to make sure you're not stepping out of bounds. If necessary, step through it in a debugger.
Alternatively... you could put this 'arr' thing in a class and access the data with get functions (or an operator overload). This way you can build in bounds checking.
Or... you could use a std container class (like a vector) and use at() to do bounds checking.