My heap is corrupt. No I’m not talking about my car, or my house, but it’s a boring programming thing. Essentially, it means somewhere, I’ve been silly and have written code that writes to memory that it shouldn’t be. This is something that is very very hard to track down.
The trouble with C++, is it lets you do silly things. Not just write to memory that isn’t yours, you could do crazy stuff like define + as meaning subtract, and vice versa. C++ is the programming practical jokers language of choice. There are even competitions to see who can write the most unintelligble crap with it.*
Of course, I try to write the most sensible, intelligible code that I can. After all, I’m the poor schmuck who has to support it, and fend off bug reports from angry customers. The BIG problem with C++ is that when you write some code that does crazy stuff, even when it goes wrong, you might not know about it until much later, maybe seconds or even minutes later, which means hundreds of thousands, if not millions of lines of code have been processed since the actual error.
In other words, you can’t look at a call stack and see where you screwed up, which you can do, in 99% of bugs. Even multithreaded bugs can be at least reasonably interrogated with the call stack and watch window.
With a heap screwup like mine, you are back to pre-debugger, stone age thinking such as.
“When did this start happening”
“What had I done before it crashed? and what had I *not* done?”
The last one is especially helpful because it rules out certain causes. My crash is NOT a result of the level editor, the unit design screen, units exiting the map, nightvision, nighttime, order-giving or path-assigning. It happens in debug, and its only been happening the last week, maximum.
So that means I’ve probabyl screwed up the new pathfinding code or the new AI code. These are two recent areas of much rewriting. I’m combing through them right now. I’ve tried various tools and debug flags to help, but sadly they either don’t run, or slow the game to unplayable speeds, where the bug will likely never trigger.
Fun fun fun!
*C++ is FAST, which is why I use it. If you think 2D games don’t need speed, try cloning GSB or GTB to run at 1920 1200 res and run smoothly on a 4 year old video card. You NEED a lot of speed for all this stuff.