I have tracked the issue down to scan_sexps_forward in syntax.c