Subject: Re: bug#21824: 25.0.50; overlay modification-hooks called with wrong buffer

From: Noam Postavsky <[email-masked]>
Date: Wed, 4 Nov 2015 19:19:27 -0500

On Wed, Nov 4, 2015 at 10:31 AM, Eli Zaretskii <[email-masked]> wrote:
> Thanks.  Unfortunately, I don't really have enough time at the moment
> to install all of that, certainly not libclang.  Is it okay if I ask
> questions and make observations, and you then try digging into this
> problem, find the answers, and post them here?

Yup, totally understandable.

> I see that yas-global-mode is turned on, which (AFAIU) means yasnippet
> tries to do its thing in every buffer, including *Messages*, right?
>

I can reproduce the problem with yas-minor-mode enabled only in the C++ buffer.

But I *can't* reproduce the problem with highlight-parenthesis-mode
only in the C++ buffer. It seems global-highlight-parenthesis-mode is
required.

> That in turn means every modification of the *Messages* buffer will,
> quite correctly, call yas--on-field-overlay-modification, provided
> that the buffer has overlays in it.

To clarify, yas--on-field-overlay-modification is *only* called as a
modification-hooks property of overlays that yasnippet creates.
Yasnippet never calls it directly.

Yasnippet only creates overlays after expanding a snippet, so this
should never occur in the *Messages* buffer (unless the user decides
to start typing and expanding snippets there). However, there are
several other packages involved.

> After this error happens, what does the following produce if invoked
> with *Messages* being the current buffer:
>
>   M-: (overlays-in (point-min) (point-max)) RET

Evaluating in the stackframe where the error is triggered:

(#<overlay from 1 to 1 in *Messages*> #<overlay from 1 to 1 in
*Messages*> #<overlay from 1 to 1 in *Messages*> #<overlay from 1 to 1
in *Messages*> #<overlay from 1 to 1 in *Messages*> #<overlay from 1
to 1 in *Messages*> #<overlay from 1 to 1 in *Messages*> #<overlay
from 1 to 1 in *Messages*>)

Afterwards it gives nil.

The "from 1 to 1" suggests overlays created by highlight-parentheses,
as I see it has a (make-overlay 0 0 nil t) call in a loop.