Given an ML-like language with commentstring=(*%s*), taking the valid program:
and selecting it all and commenting with gc gives:
(*(**)*)
(*val x = (*)
(* 1)*)
The (*) on the second line is then treated as an unmatched open comment.
The cause of this bug is probably the same as in some past issues (#3, #29, #40, etc), but the fix might be simpler here since you'd just need to ensure that there's always a space between the last character in a line and the closing comment.