Subject: bug#60768: 30.0.50; edebug-instrument-function off by one

From: Stefan Monnier <[email-masked]>
Date: Mon, 16 Jan 2023 21:28:56 -0500

> diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
> index 2f7d03e..0ac51ad 100644
> --- a/lisp/emacs-lisp/edebug.el
> +++ b/lisp/emacs-lisp/edebug.el
> @@ -518,6 +518,7 @@ edebug-read-top-level-form
>          ;; Don't enter Edebug while doing that, in case we're trying to
>          ;; instrument things like end-of-defun.
>          (edebug-active t))
> +    (save-excursion (end-of-defun))
>      (end-of-defun)
>      (beginning-of-defun)
>      (prog1
>
> i.e., add one call to end-of-defun whose result is thrown away, before
> the _real_ call to end-of-defun, the problems go away.
>
> The reason seems to be that end-of-defun calls scan-sexps, and the
> first call to scan-sexps does something that wasn't done before.
>
> Stefan, any ideas what could that be?  Any hints where to look?

Sounds like a problem with the on-the-fly calls to `syntax-propertize`.
Maybe tracing `internal--syntax-propertize` would give us a hint.

        Stefan