Can no longer upload ANY sketches to Arduino Mega 2560 - timeout at upload

I fixed the problem by reading the bootloader from a working arduino, and uploading it to the non-functional ones with an AVRISP mkII. As for the the sketch that was causing the problem, I believe it was from dereferencing a null pointer, which was being interpreted as the address of an array. I still find it strange that I was able to write to the bootloader at runtime.