Nick’s 12-Step Guide to Fixing Mysterious Memory Errors
- Write some code and run it. Fail.
- Add a bunch of debug statements and rerun the code. Fail.
- Use GDB to find segmentation faults, bus errors, and bad access errors. Fail.
- Try to determine why GDB is setting breakpoints in functions that don’t exist. Fail.
- Curse GDB and its children, yea, unto the tenth generation!
- Rewrite memory allocation code and rerun the code. Fail.
- Rearrange contents of data structures and rerun the code. Fail.
- Change all variables to 4-byte types. Fail.
- Appeal to the superior coding ability of The Bruce. Fail.
- Examine the memory at the byte level and watch as your data structure is flipped, split, rearranged, and regurgitated. Wonder if God can exist in a world where bytes change their hexadecimal values on a whim.
- Blame Linus Torvalds, Steve Jobs, Reid Simmons, Alan Turing, Charles Babbage, and anyone else but yourself who could have any affect on a computer’s memory.
- Finally succumb to the dark powers and sacrifice a squirrel on top of a flaming ergonomic Microsoft keyboard while chanting “Arise, robot! Robot, arise!” repeatedly.
Don’t be terribly surprised that the last step works.