Some versions of the bootloader have a "monitor" mode that is activated by sending three consecutive '!' characters. This monitor mode allows you to read and write memory from a serial console. Unfortunately the idiot person who implemented the code didn't put in any protection to prevent the monitor from being triggered during memory upload! If your bootloader has this "feature" (typically the Mega and other larger processors) you have to remember to never use three '!' characters in a row.
...maybe it could be a good feature for the arduino environment to check for this in the hex to be uploaded. But then again the fault is, as you say, in the bootloader code...