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

From: Toby Cubitt <[email-masked]>
Date: Wed, 8 Jan 2014 03:37:04 +0000

On Mon, Jan 06, 2014 at 07:32:45PM -0500, Barry OReilly wrote:
> Don't know yet if the code change belongs in Undo Tree or Emacs but
> the recipe is:
> 
>   • Start Emacs in scratch buffer with global-undo-tree-mode enabled
>   • Go to BOB and insert "xxx"
>   • Select first line
>   • undo-tree-undo in region
>   • undo-tree-redo in region
>   • undo-tree-visualize
>   • Navigate down (redo)*
>   • Navigate up (undo)
> 
> Upon the navigate up, this error occurs:
> 
>   Debugger entered--Lisp error: (error "Unrecognized entry in undo list
> undo-tree-canary")
>      signal(error ("Unrecognized entry in undo list undo-tree-canary"))
>      error("Unrecognized entry in undo list %S" undo-tree-canary)
>      primitive-undo(1 (undo-tree-canary))
>      undo-tree-undo-1(1)
>      undo-tree-visualize-undo(1)
>      call-interactively(undo-tree-visualize-undo nil nil)
>      command-execute(undo-tree-visualize-undo)
>
> * 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)

OK, I can reproduce this. Here's a precise recipe:

1.  emacs -Q
2.  M-x load-file ~/undo-tree.elc
3.  M-x global-undo-tree-mode
4.  M-<
5.  type "xxx"
6.  C-a, C-SPC, C-e
7.  C-/
8.  C-g
9.  C-a, C-SPC, C-e
10. C-?
11. C-g
12.  C-x u
13. <down>
14. <up>

For me, this causes Emacs to hang in an infinite loop. I managed to
trigger the "Unrecognized entry" error once, but now I can't reproduce
it.

(Unfortunately, because of the way Emacs' undo system works, tiny changes
to the precise sequence of commands can affect how it behaves - even
apparently benign things like moving the point. I've never encountered so
many Heisenbugs as when coding undo-tree :-/

This looks like an undo-tree bug to me. The "Unrecognised entry" error
suggests the undo-tree-canary symbol has somehow ended up in a
`buffer-undo-tree' entry. That should never happen.

However, I don't understand why this should depend on which Emacs version
one runs.

I'll keep investigating. If you can rediscover the precise sequence of
steps required to trigger the error instead of the hang, please send them
to me!

Best,
Toby

-- 
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