From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yutian Li | =?UTF-8?Q?=E6=9D=8E=E9=9B=A8=E7=94=B0?= Newsgroups: gmane.emacs.bugs Subject: bug#21819: 24.5; Overlay modification function called with wrong arguments Date: Tue, 3 Nov 2015 12:59:18 -0800 Message-ID: References: <83fv0nw1ao.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1446584435 28905 80.91.229.3 (3 Nov 2015 21:00:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Nov 2015 21:00:35 +0000 (UTC) Cc: 21819@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 03 22:00:17 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ztigj-0001D9-2h for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Nov 2015 22:00:17 +0100 Original-Received: from localhost ([::1]:50980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztigi-0006l7-Gh for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 Nov 2015 16:00:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtigZ-0006gh-4D for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 16:00:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtigV-0000Py-U7 for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 16:00:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:32912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtigV-0000Pu-NV for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 16:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZtigV-00050J-8s for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2015 16:00:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yutian Li | =?UTF-8?Q?=E6=9D=8E=E9=9B=A8=E7=94=B0?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Nov 2015 21:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21819 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 21819-submit@debbugs.gnu.org id=B21819.144658438119185 (code B ref 21819); Tue, 03 Nov 2015 21:00:03 +0000 Original-Received: (at 21819) by debbugs.gnu.org; 3 Nov 2015 20:59:41 +0000 Original-Received: from localhost ([127.0.0.1]:51853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ztig8-0004zM-FM for submit@debbugs.gnu.org; Tue, 03 Nov 2015 15:59:41 -0500 Original-Received: from mail-ob0-f175.google.com ([209.85.214.175]:33710) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ztifn-0004yv-Py for 21819@debbugs.gnu.org; Tue, 03 Nov 2015 15:59:38 -0500 Original-Received: by obbwb3 with SMTP id wb3so23546247obb.0 for <21819@debbugs.gnu.org>; Tue, 03 Nov 2015 12:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=zUAnWr3Z/T9sAyLaQGblUscUD5/Fur533JBemvyNvlY=; b=n3B1siMO/nunwxwf34eIrguve70QHwOp/Pl+pRfZZF6QRNnAW4d0vpDjyZU+imb7jw WxtIrbEU3S+3wmbg7ii/X43u/QSJzqQpfpx1Ie8+hz6gA2YxsxXC+NYVRVxjIZkvlHJs h7QTPH8aK/f3Tc54Hq/ij1fYOUaZMoOomMcubLcTX3213dPeWlBM+CFfulYfOOIVrl5v 5gKzaS63TSaGU665dradDK2pGHrQDuFcMkkYThFeH5A35RywwrmcJKQSifakCmM/kXfQ 7G9ap5hi488in5FAOPRN+uYx8Z6gcJiVv+HxuPnp5rqVVIFAk7iWfk1EUoIjfleNGv4C OHlQ== X-Received: by 10.182.131.132 with SMTP id om4mr6456288obb.72.1446584359028; Tue, 03 Nov 2015 12:59:19 -0800 (PST) Original-Received: by 10.202.227.129 with HTTP; Tue, 3 Nov 2015 12:59:18 -0800 (PST) In-Reply-To: <83fv0nw1ao.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:108387 Archived-At: On Tue, Nov 3, 2015 at 7:27 AM, Eli Zaretskii wrote: >> Date: Tue, 3 Nov 2015 00:24:41 -0800 >> From: Yutian Li | =E6=9D=8E=E9=9B=A8=E7=94=B0 >> >> 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. > Yes. The init file is [here](https://gist.github.com/hotpxl/cfad63d5e88ed164bc76). It will automatically install dependencies. You have to manually `M-x irony-install-server` to install Irony. Then you could open up any C++ file. Define a function with a long name, and some parameters. Then when you try to type the name of the function, you will get completion candidates. If you choose the candidate, Irony will invoke YASnippet to lay out a template for the parameters, so you could tab through the parameters. If you then quickly fill the parameters and tab through, you will see the error. >> 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 don't think it *should* call the modification hook. I think this is where the bug happens. It basically calls the modification hook function with the overlay from C++ buffer, and positions from the `*Messages*` buffer. >> 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.