Subject: bug#61395: 28.2; bug-reference warning seems incorrect

From: Tassilo Horn <[email-masked]>
Date: Fri, 10 Feb 2023 18:21:09 +0100

Tom Tromey <[email-masked]> writes:

>> I'll have a look later today!
>
> It seems difficult to reproduce.  I can't do it reliably.
>
> My co-worker Kévin suggested that perhaps the problem is here, in
> bug-reference-fontify:
>
>       (while (and (< (point) end-line)
>                   (re-search-forward bug-reference-bug-regexp end-line 'move))
>         (when (or (not bug-reference-prog-mode)
>                   ;; This tests for both comment and string syntax.
>                   (nth 8 (syntax-ppss)))
>
> ... with the question being whether the call to syntax-ppss needs to
> be wrapped in save-match-data.

Hm, I've tried somthing like

  (while (re-search-forward "\\(NILP\\)\\(.*\\)$" nil t)
    (syntax-ppss-flush-cache (point-min))
    (let ((md (match-data)))
      (syntax-ppss)
      (unless (equal md (match-data))
        (error "Match-data clobbered: %S %S" md (match-data)))))

many times in buffer.c but `syntax-ppss' doesn't seem to clobber
match-data.

If you can reproduce the issue, try changing
`bug-reference--overlay-bounds' so that the check

  (member bug-reference-bug-regexp
          bug-reference--nonconforming-regexps)

isn't performed inhibiting the warning for this regexp and add some more
info to the warning message like (match-string N) for N in 0..9.  If the
match-data isn't about matches of `bug-reference-bug-regexp', we are on
the right track, i.e., someone clobbers our match data.

Bye,
Tassilo