This used to happen in C for me. Basically, you are trying to print a string which has overflowed the allocated length and you get junk printed on the string. C-Strings are null terminated and the system will keep printing till it encounters a null. So, bounds checking and buffer overflows are also hard problems.