Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?

From: William Rankin <[email-masked]>
Date: Sat, 7 Mar 2020 22:16:56 +1000

> On 7 Mar 2020, at 9:04 pm, Eli Zaretskii <[email-masked]> wrote:
> 
>> Hmm given the way it moves point, I would put money on this not being my
>> init. I'm not smart enough to write something that would work in such a
>> sporadic way.
> 
> I didn't mean something you wrote, I meant some feature you turn on
> that is not turned on by default, a feature that is part of Emacs or
> some third-party package you are using.

Ah I see. Okay, that does increase the surface area.

>> Given the impending release of 27.1 maybe there are other avenues I can
>> check too?
> 
> You could try running under GDB with a breakpoint in set_point_both
> and temp_set_point_both, with breakpoint commands that show the C and
> Lisp backtrace and then immediately continue the program.  Let me know
> if you need more detailed instructions for setting this up.

I should be able to figure this out and report back.

> Can you describe the issue in more detail?  Are you saying this
> happens when Emacs is idle, i.e. you are not typing any commands and
> no sub-processes should be running?  And what exactly do you see when
> this happens?  Also, do you see any error messages in *Messages*? when
> that happens?
> 
> FWIW, I don't see anything like this on my system in Emacs 27.0.90, so
> I have hard time believing that something as basic as JIT font-lock
> could do this, at least not by default.

I've only observed this after Emacs has been open for more than a few
hours or overnight.

It will only happen after Emacs is idle for a few seconds, i.e. no user
input.

The point will start jumping to different positions in the buffer, and 
this will then repeat at regular intervals of ~0.5 seconds per jump. 
These positions do not appear totally random, but seem like jumps of a 
similar sized chunk of text, like they are being calculated.

I think the only process running is ispell (enchant).

There are no error messages in *Messages*.

C-g does not immediately stop point jumping, however, if I give more
input (e.g. C-n/p or C-x o, etc.) then either this will stop point
jumping, or will delay it for ~2 seconds, and then point starts
jumping again. This repetition only happens a once or twice before it
seems to "finish" and the problem appears gone.

There is this in my init:

(advice-add 'mark-word :before
            (lambda (&rest args)
              (unless (looking-at-p "\\b")
                (backward-word))))

Could this be causing such havoc??