Subject: Re: bug#73041: 30.0.90; track-changes-mode logs warnings (#70541 regression? not actually fixed?)

From: Eric Gillespie <[email-masked]>
Date: Thu, 10 Oct 2024 11:21:21 -0500

Hi Stefan!

Stefan Monnier <[email-masked]> writes:

> If you're able to try Emacs `master` (which would be helpful), then the
> patch I sent doesn't apply to it (any more), so please use the patch
> below instead and add `(setq track-changes-record-errors 'trace)` to your
> init file so as to activate the additional recording.

I applied that patch to master and have been using it every day.
This morning I FINALLY hit it...  on a NEW FILE, where I'm
switching in and out of a branch with a new file.  I'm not sure
all the previous occurrences were on new files, but I could
believe they were.

Anyway, with that clue in hand, I was able to narrow it down to a
simple reproduction recipe.

I'm running emacs built from this commit to master:

commit ef587bf6b46b2ea3ef91b260ac2542666081260d
Author: Stefan Monnier <[email-masked]>
Date:   Thu Oct 3 13:32:09 2024

With your cl-assert patch applied on top of that.

GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, cairo version 1.18.2) of 2024-10-04

(We won't use git in the recipe, but eglot requires project-root
which I can't get to work without git (which also seems like a
bug, albeit unrelated...))

 1. cargo new --vcs git foo
 2. echo 'mod foo;' >> foo/src/main.rs
 3. emacs -Q foo/src/foo.rs
    (foo.rs DOES NOT EXIST YET -- that is part of the bug)
 4. M-x rust-ts-mode RET
 5. (progn (setq track-changes-record-errors 'trace) (setq debug-on-error t))
 6. C-x C-f main.rs RET
 7. M-x eglot RET
 8. echo 'struct foo;' > foo/src/foo.rs
 9. C-x C-f foo.rs RET
10. yes RET

BOOM TODAY

Note that #8 must be an edit behind emacs's back.  In my daily
life, what's happening there is I had the buffer 'foo.rs' open
earlier while working on the branch where I added it, I'd
switched to a branch without it, and then I switch back, and
everything fell apart when I reverted it.

Debugger entered--Lisp error: (cl-assertion-failed ((track-changes--sane-state-p) nil))
  cl--assertion-failed((track-changes--sane-state-p))
  track-changes--before(1 13)
  track-changes--after(1 13 0)
  insert-file-contents("/home/epg/tmp/emacsbug73041/foo/src/foo.rs" t nil nil if-regular)
  revert-buffer-insert-file-contents--default-function("/home/epg/tmp/emacsbug73041/foo/src/foo.rs" nil)
  revert-buffer--default(t t)
  revert-buffer(t t)
  find-file-noselect("~/tmp/emacsbug73041/foo/src/foo.rs" nil nil t)
  find-file("~/tmp/emacsbug73041/foo/src/foo.rs" t)
  funcall-interactively(find-file "~/tmp/emacsbug73041/foo/src/foo.rs" t)
  call-interactively(find-file nil nil)
  command-execute(find-file)

I hope this is enough to go on now.

Thanks!

-- 
Eric Gillespie <*> [email-masked]