Subject: bug#60352: 30.0.50; Keep getting "Error in syntax_table logic for to-the-end intervals"

From: Stefan Monnier <[email-masked]>
Date: Tue, 27 Dec 2022 10:13:21 -0500

>> Debugger entered--Lisp error: (error "Error in syntax_table logic for to-the-end intervals")
>>   (re-search-forward "\\(?:\\(?:\\<DEADLINE: *\\(\\(?:<\\(?:[[:digit:]]\\{4\\}-[..." nil move)
>>
>> It only happens in Emacs 30 (master) and is not regular.
>>
>> The error sounds like some kind of internal error.

It is, indeed.

>> Does it signify some Emacs issue? Or may it be third-party code issue?

No, it's a bug in the C code somewhere.
Presumably somewhere between the `regexp-emacs.c` code and the
`syntax.c` code.

The regexp code keeps a global state in `gl_state` to speed up looks up
of the `syntax-table` text-property.  The above error indicates that
this global state is inconsistent for some reason.

Maybe we somehow ran a regexp search during the regexp search?
I know this can happen via the automatic calls to `syntax-propertize`,
but `syntax.c:parse_sexp_propertize` is careful to (re)call
`SETUP_SYNTAX_TABLE` after running ELisp code, so that shouldn't be the
source of the problem.

Maybe there's some other way to re-enter regexp search and that one
isn't careful to call `SETUP_SYNTAX_TABLE` before returning to the outer
regexp search?

        Stefan