GNU bug report logs - #25599
26.0.50; "Marker does not point anywhere" error signaled by primitive-undo near an overlay with an auto-removal insert-in-front-hooks value

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dgutov <at> yandex.ru>

Date: Wed, 1 Feb 2017 14:19:01 UTC

Severity: normal

Tags: patch

Found in version 26.0.50

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25599 in the body.
You can then email your comments to 25599 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Wed, 01 Feb 2017 14:19:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dmitry Gutov <dgutov <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 01 Feb 2017 14:19:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; "Marker does not point anywhere" error signaled by
 primitive-undo near an overlay with an auto-removal insert-in-front-hooks
 value
Date: Wed, 1 Feb 2017 16:18:27 +0200
In diff-hl, we create overlays to paint markers on the fringe. The
overlays are set to be deleted when text inside (or very close nearby)
is modified, for better user experience. Yet it seems to clash with 
"undo", original bug report here: 
https://github.com/dgutov/diff-hl/issues/84

Here's how to reproduce the problem without diff-hl installed:

1. Replace the contents of the scratch buffer with this:

--->
;; aaaaaaaaaaaaa
;; bbbbbbbbbbbbb

(defun overlay-modified (ov after-p _beg _end &optional length)
  (unless after-p
    (when (overlay-buffer ov)
      (delete-overlay ov))))

(save-excursion
  (goto-char (point-min))
  (let ((ov (make-overlay (line-beginning-position 2) 
(line-end-position 2))))
    (overlay-put ov 'insert-in-front-hooks '(overlay-modified))))
<---

2. Evaluate both forms at the end, the one that defines
`overlay-modified' and the one that creates the overlay.

3. Select the whole first line (;; aaa...), including the newline, so
that the region ends at the beginning of the second line.

4. Press C-w, killing the region, then M-x undo.

5. See the error "Marker does not point anywhere".

The backtrace looks like this:

Debugger entered--Lisp error: (error "Marker does not point anywhere")
  primitive-undo(1 ((#(";; aaaaaaaaaaaaa\n" 0 1 (fontified t face 
font-lock-comment-delimiter-face) 1 3 (fontified t face 
font-lock-comment-delimiter-face) 3 16 (fontified t face 
font-lock-comment-face) 16 17 (fontified t face font-lock-comment-face)) 
. 1) (#<marker at 1 in -scratch-> . -17) (#<marker in no buffer> . -17) 
(#<marker in no buffer> . -17) 18 nil undo-tree-canary))
  undo-more(1)
  undo(nil)
  funcall-interactively(undo nil)

The problem is not new, I see it in 24.5 as well.

In GNU Emacs 26.0.50.5 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2017-01-23 built on zappa
Repository revision: 03de82fe7ca09ab40fbcae394d4fcdfe3374496e
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:	Ubuntu 16.04.1 LTS




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Wed, 08 Mar 2017 16:16:02 GMT) Full text and rfc822 format available.

Message #8 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: nitish chandra <nitishchandrachinta <at> gmail.com>
To: 25599 <at> debbugs.gnu.org
Subject: Why edit markers after insert?
Date: Wed, 8 Mar 2017 21:44:59 +0530
[Message part 1 (text/plain, inline)]
In primitive-undo in simple.el, aroud line 2550 (in master) we adjust the
markers after the insertion.

(dolist (adj valid-marker-adjustments)
               (set-marker (car adj)
                           (- (car adj) (cdr adj))))

Why is this needed? Won't insert take care of adjusting the markers?
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Wed, 08 Mar 2017 17:40:01 GMT) Full text and rfc822 format available.

Message #11 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: nitish chandra <nitishchandrachinta <at> gmail.com>
Cc: 25599 <at> debbugs.gnu.org
Subject: Re: bug#25599: Why edit markers after insert?
Date: Wed, 08 Mar 2017 18:39:23 +0100
On Mär 08 2017, nitish chandra <nitishchandrachinta <at> gmail.com> wrote:

> In primitive-undo in simple.el, aroud line 2550 (in master) we adjust the
> markers after the insertion.
>
> (dolist (adj valid-marker-adjustments)
>                (set-marker (car adj)
>                            (- (car adj) (cdr adj))))
>
> Why is this needed? Won't insert take care of adjusting the markers?

Only marker originally pointing inside the deleted region were recorded
here, and this is to make sure they regain their previous position after
the reinsertion.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Wed, 08 Mar 2017 18:10:02 GMT) Full text and rfc822 format available.

Message #14 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: nitish chandra <nitishchandrachinta <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 25599 <at> debbugs.gnu.org
Subject: Re: bug#25599: Why edit markers after insert?
Date: Wed, 8 Mar 2017 23:38:49 +0530
[Message part 1 (text/plain, inline)]
> Only marker originally pointing inside the deleted region were recorded
> here, and this is to make sure they regain their previous position after
> the reinsertion.
>

I removed this part of the code to see what changes.

1. I put a marker in a line
2. Deleted the line
3. Undo-ed the delete

The marker is still in the proper place. So markers in the deleted string
do seem to regain their position properly.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Wed, 08 Mar 2017 18:19:02 GMT) Full text and rfc822 format available.

Message #17 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: nitish chandra <nitishchandrachinta <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 25599 <at> debbugs.gnu.org
Subject: Re: bug#25599: Why edit markers after insert?
Date: Wed, 8 Mar 2017 23:47:49 +0530
[Message part 1 (text/plain, inline)]
Sorry, the above process threw some warnings. I didn't notice them before:

Warning (emacs): Encountered (#<marker at 1 in *scratch*> . -14) entry in
undo list with no matching (TEXT . POS) entry



On 8 March 2017 at 23:38, nitish chandra <nitishchandrachinta <at> gmail.com>
wrote:

>
> Only marker originally pointing inside the deleted region were recorded
>> here, and this is to make sure they regain their previous position after
>> the reinsertion.
>>
>
> I removed this part of the code to see what changes.
>
> 1. I put a marker in a line
> 2. Deleted the line
> 3. Undo-ed the delete
>
> The marker is still in the proper place. So markers in the deleted string
> do seem to regain their position properly.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Thu, 09 Mar 2017 19:40:02 GMT) Full text and rfc822 format available.

Message #20 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: nitish chandra <nitishchandrachinta <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 25599 <at> debbugs.gnu.org
Subject: Re: bug#25599: Why edit markers after insert?
Date: Fri, 10 Mar 2017 01:09:31 +0530
[Message part 1 (text/plain, inline)]
The problem is being caused by insert invalidating some of the markers. So
before adjusting the markers, we can check if the marker is valid or not.
Following is a patch that does this.
[Message part 2 (text/html, inline)]
[0001-Check-for-invalid-markers-after-insertion-in-undo.patch (text/x-patch, attachment)]

Added tag(s) patch. Request was from nitish chandra <nitishchandrachinta <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 16 Mar 2017 16:44:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Sun, 14 May 2017 01:14:02 GMT) Full text and rfc822 format available.

Message #25 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: nitish chandra <nitishchandrachinta <at> gmail.com>,
 Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 25599 <at> debbugs.gnu.org
Subject: Re: bug#25599: Why edit markers after insert?
Date: Sun, 14 May 2017 04:12:58 +0300
On 09.03.2017 21:39, nitish chandra wrote:
> The problem is being caused by insert invalidating some of the markers. 
> So before adjusting the markers, we can check if the marker is valid or 
> not. Following is a patch that does this.

Thanks, Nitish. The patch works for me.

Could someone else more familiar with undo give a second opinion, please?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25599; Package emacs. (Sun, 11 Jun 2017 18:09:02 GMT) Full text and rfc822 format available.

Message #28 received at 25599 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 25599 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>,
 nitish chandra <nitishchandrachinta <at> gmail.com>
Subject: Re: bug#25599: Why edit markers after insert?
Date: Sun, 11 Jun 2017 14:10:08 -0400
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 09.03.2017 21:39, nitish chandra wrote:
>> The problem is being caused by insert invalidating some of the
>> markers. So before adjusting the markers, we can check if the marker
>> is valid or not. Following is a patch that does this.
>
> Thanks, Nitish. The patch works for me.
>
> Could someone else more familiar with undo give a second opinion, please?

Not that I'm very familiar with the undo code, but the patch seems
obviously correct to me.

+               ;; insert might have invalidated some of the
+               ;; markers. We update only the currently valid
+               ;; markers. See bug#25599

I would augment the comment to specifically mention modification hooks
though (missing double spacing too).




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Sat, 17 Jun 2017 01:07:02 GMT) Full text and rfc822 format available.

Notification sent to Dmitry Gutov <dgutov <at> yandex.ru>:
bug acknowledged by developer. (Sat, 17 Jun 2017 01:07:02 GMT) Full text and rfc822 format available.

Message #33 received at 25599-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: npostavs <at> users.sourceforge.net
Cc: 25599-done <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>,
 nitish chandra <nitishchandrachinta <at> gmail.com>
Subject: Re: bug#25599: Why edit markers after insert?
Date: Sat, 17 Jun 2017 04:06:35 +0300
On 6/11/17 9:10 PM, npostavs <at> users.sourceforge.net wrote:

> Not that I'm very familiar with the undo code, but the patch seems
> obviously correct to me.
> 
> +               ;; insert might have invalidated some of the
> +               ;; markers. We update only the currently valid
> +               ;; markers. See bug#25599
> 
> I would augment the comment to specifically mention modification hooks
> though (missing double spacing too).

Good point. Added and pushed.

Thanks all! Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 15 Jul 2017 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 342 days ago.

Previous Next


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