The precise condition is target length + repeats > input length. This has likelihood 0 and so the negative log likelihood (that ctc loss is) is infinite. Zeroing that will help there, but actually distort your score of used in validation.
Best regards
Thomas