Here is a possibility. Do you have interrupts disabled while erasing?
If you don't disable interrupts, it will work while single stepping, but crash when not.
It because the vectors are not available while erasing and if one happens, the machine will crash.