GNU bug report logs - #21824
25.0.50; overlay modification-hooks called with wrong buffer

Previous Next

Package: emacs;

Reported by: Noam Postavsky <npostavs <at> users.sourceforge.net>

Date: Wed, 4 Nov 2015 03:07:02 UTC

Severity: normal

Merged with 21819

Found in versions 24.5, 25.0.50

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#21819: closed (24.5; Overlay modification function called
 with wrong arguments)
Date: Sat, 07 Nov 2015 02:26:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 6 Nov 2015 21:24:50 -0500
with message-id <CAM-tV-9UDXdVu_+akY5RxW2cY9gFo7N8wwo+djhaRsBRK28W3Q <at> mail.gmail.com>
and subject line Re: bug#21824: 25.0.50; overlay modification-hooks called with wrong buffer
has caused the debbugs.gnu.org bug report #21824,
regarding 24.5; Overlay modification function called with wrong arguments
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
21824: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21824
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Yutian Li | 李雨田 <hotpxless <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; Overlay modification function called with wrong arguments
Date: Tue, 3 Nov 2015 00:24:41 -0800
Hi.

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.

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.

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.

Best regards,
Yutian LI | 李雨田

Mobile: +1 (650) 798-9092
E-mail: hotpxless <at> gmail.com

Computer Science Department
Stanford University


[Message part 3 (message/rfc822, inline)]
From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 21824-done <at> debbugs.gnu.org
Subject: Re: bug#21824: 25.0.50;
 overlay modification-hooks called with wrong buffer
Date: Fri, 6 Nov 2015 21:24:50 -0500
On Fri, Nov 6, 2015 at 10:23 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> (It sounds like a very old bug, as all the
> pieces of the puzzle were not touched in at least 15 years.)

Quite likely, the circumstances required to trigger it are pretty specific.

>
> Please see if the original bug is solved by the latest master.

Yes, it's fixed.

>
> Btw, any idea how come overlays wound up in *Messages* in the original
> scenario?

global-highlight-parentheses-mode puts overlays in every buffer.

> Actually, would you like converting your test case into a test, and
> post a patch to the test suite to that effect?  TIA.

Something like this? I'm not sure where to put it.

(ert-deftest overlay-modification-hooks ()
  "Test for bug#21824."
  (let ((buf nil))
    (with-temp-buffer
      (insert "123")
      (overlay-put (make-overlay 1 3) 'modification-hooks
                   (list (lambda (ov &rest _)
                           (setq buf (current-buffer)))))
      (goto-char 2)
      (insert "x")
      (with-current-buffer "*Messages*"
        (make-overlay 1 1))
      (message "a message")
      (message "a message")
      (should (eq buf (current-buffer))))))


This bug report was last modified 6 years and 311 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.