Subject: bug#16523: Undo Tree regression: (error "Unrecognized entry in undo list undo-tree-canary")

From: Toby Cubitt <[email-masked]>
Date: Wed, 22 Jan 2014 17:08:44 +0000

On Tue, Jan 21, 2014 at 10:23:37PM -0500, Barry OReilly wrote:
> > * Sometimes the navigate down hangs with backtrace:
> >
> >   Debugger entered--Lisp error: (quit)
> >      undo-tree-copy-list((nil))
> >      undo-tree-redo-1(1)
> >      undo-tree-visualize-redo(1)
> >      call-interactively(undo-tree-visualize-redo nil nil)
> >      command-execute(undo-tree-visualize-redo)
> 
> In a reproduction of this, at the start of undo-tree-copy-list,
> undo-list is:
> 
>   (nil (undo-tree-id3 . -2))
> 
> Then in this while loop:
> 
>   (while (null copy)
>     (setq copy
>           (undo-tree-restore-GC-elts-from-pool (pop undo-list))))
> 
> undo-tree-restore-GC-elts-from-pool returns nil for both elements, so
> the while loop never ends. Perhaps you want instead (ignore-whitespace
> diff):

Could well be. Thanks a lot for the patch!

I need to step through the minimal example and remember what this code is
supposed to be doing, and then either apply your patch or figure out what
the correct fix is (to this, and the other undo-list-pop-changeset issue
you pointed out, which at the moment seem to be separate issues).

Cheers,
Toby

> --- a/emacs/lisp/undo-tree.el    Fri Jan 17 19:18:15 2014 -0500
> +++ b/emacs/lisp/undo-tree.el    Tue Jan 21 22:17:50 2014 -0500
> @@ -1690,13 +1690,13 @@
>  (defun undo-tree-copy-list (undo-list)
>    ;; Return a deep copy of first changeset in `undo-list'. Object id's are
>    ;; replaced by corresponding objects from `buffer-undo-tree' object-pool.
> -  (when undo-list
>      (let (copy p)
>        ;; if first element contains an object id, replace it with object
> from
>        ;; pool, discarding element entirely if it's been GC'd
> -      (while (null copy)
> +    (while (and undo-list (null copy))
>      (setq copy
>            (undo-tree-restore-GC-elts-from-pool (pop undo-list))))
> +    (when copy
>        (setq copy (list copy)
>          p copy)
>        ;; copy remaining elements, replacing object id's with objects from

-- 
Dr T. S. Cubitt
Royal Society University Research Fellow
and Fellow of Churchill College, Cambridge
Centre for Quantum Information
DAMTP, University of Cambridge

email: [email-masked]
web:   www.dr-qubit.org