all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Yutian Li | 李雨田" <hotpxless@gmail.com>
Cc: 21819@debbugs.gnu.org
Subject: bug#21819: 24.5; Overlay modification function called with wrong arguments
Date: Tue, 03 Nov 2015 17:27:43 +0200	[thread overview]
Message-ID: <83fv0nw1ao.fsf@gnu.org> (raw)
In-Reply-To: <CABvSBnjLk-U=kxQLNx6F_o4tW4BPHpoh0+6+68CS2h57pno5EQ@mail.gmail.com>

> Date: Tue, 3 Nov 2015 00:24:41 -0800
> From: Yutian Li | 李雨田 <hotpxless@gmail.com>
> 
> This happens on both Mac and GNU/Linux with latest release of Emacs. I
> also tried the master branch of `git://git.sv.gnu.org/emacs.git` and
> it still exists.
> 
> The discussion that led to the discovery of the bug is
> [here](https://github.com/capitaomorte/yasnippet/issues/607). There is
> a stack trace on the OP. Some guesses in the bottom. There is also
> instructions to reproduce this.

Thanks.

I've read that discussion.  Unfortunately, the instruction for
reproducing the problem are not clear to me, I'd appreciate if someone
could post them here in their entirety, ideally a single Lisp file
that needs to be 'load'ed into "emacs -Q" after installing the minimal
number of add-on packages that are strictly necessary for reproducing
the problem.

> The direct cause is the modification hook registered with the overlay
> is called with apparently wrong arguments. The hook function is
> registered with an overlay in the C++ buffer, but called with `beg`
> and `end` referring to positions probably in the `*Messages*` buffer.
> As the stack trace shows, Flycheck called `message` to display a
> message indicating syntax errors, and `message` somehow invokes the
> modification hook function, which was defined in C++ buffer but called
> now in `*Messages*` buffer.

It is entirely not clear to me how come a call to 'message' caused an
overlay modification hook, probably set up by yasnippet, to be
invoked.  This is crucial information in order to investigate the
problem, but AFAICS it's missing from the discussion you cite and from
your report.

> I traced into the Emacs source file `src/buffer.c`.  There is a
> function `report_overlay_modification`. It *should* (I guess) be
> called with `after` set to `false` and `true` alternatively. But on
> the erroneous invocation, it is called with `after` set to `true`
> twice consecutively. The first call `_beg` and `_end` are normal small
> integer (inside C++ buffer). The second call they are huge and must
> refer to the `*Messages*` buffer. Inside the call, it uses a global
> array to store overlay modification hook functions. Now it's called
> twice consecutively with `after` set to `true`, it must have reused
> old hook functions, hence the call to our function with correct
> overlay but wrong cursor. Because on a call with `after` set to
> `false`, it will "clear" the hook functions.

Thanks for looking into this, but without the information showing how
we wind up in 'report_overlay_modification' when some Lisp code called
'message', it is impossible to follow your reasoning.  E.g., it is
quite possible that the Lisp code in question sets up the modification
hook incorrectly, or maybe the modification hook should check the
value of the current buffer to avoid the problem.

In general, 'report_overlay_modification' is called immediately before
a change to a buffer that has overlays, and immediately after a
change.  The value of the AFTER argument depends on which one is it.
So just given the fact you see 2 invocations with AFTER set to true
does not yet mean there's a problem in Emacs core, it could be a
legitimate call due to the fact that *Messages* gets changed when
'message' is called.

Thanks.





  reply	other threads:[~2015-11-03 15:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03  8:24 bug#21819: 24.5; Overlay modification function called with wrong arguments Yutian Li | 李雨田
2015-11-03 15:27 ` Eli Zaretskii [this message]
2015-11-03 20:59   ` Yutian Li | 李雨田

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83fv0nw1ao.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=21819@debbugs.gnu.org \
    --cc=hotpxless@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.