GNU bug report logs - #39967
27.0.90; how to debug point moving erratically?

Previous Next

Package: emacs;

Reported by: William Rankin <william <at> bydasein.com>

Date: Sat, 7 Mar 2020 04:07:02 UTC

Severity: normal

Tags: moreinfo

Found in version 27.0.90

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 39967 in the body.
You can then email your comments to 39967 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#39967; Package emacs. (Sat, 07 Mar 2020 04:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to William Rankin <william <at> bydasein.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 07 Mar 2020 04:07:02 GMT) Full text and rfc822 format available.

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

From: William Rankin <william <at> bydasein.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.90; how to debug point moving erratically?
Date: Sat, 07 Mar 2020 13:49:33 +1000
Hello,

I've been on the emacs-27 branch for about six months, and every now and then
the point will begin erratically jumping around the current buffer without
input. (I only got to addessing it now due to the impending release of 27.1.)

Some observations: This only happens about once a week. C-g has no effect.
There's no clues in *Messages* buffer. Point movement is beyond visible portion
of buffer. It usually happens in emacs-lisp-mode buffers that have been open a
few hours, but I've experienced it in other modes too.

It seems like it could be font-lock/jit-lock moving point around outside of a
save-excursion, but I know no way of confiming this.

How should I go about debugging this?


GNU Emacs 27.0.90 (build 2, x86_64-apple-darwin19.3.0, NS appkit-1894.30 Version
10.15.3 (Build 19D76)) of 2020-03-05




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 08:01:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: William Rankin <william <at> bydasein.com>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 07 Mar 2020 10:00:43 +0200
> From: William Rankin <william <at> bydasein.com>
> Date: Sat, 07 Mar 2020 13:49:33 +1000
> 
> I've been on the emacs-27 branch for about six months, and every now and then
> the point will begin erratically jumping around the current buffer without
> input. (I only got to addessing it now due to the impending release of 27.1.)
> 
> Some observations: This only happens about once a week. C-g has no effect.
> There's no clues in *Messages* buffer. Point movement is beyond visible portion
> of buffer. It usually happens in emacs-lisp-mode buffers that have been open a
> few hours, but I've experienced it in other modes too.
> 
> It seems like it could be font-lock/jit-lock moving point around outside of a
> save-excursion, but I know no way of confiming this.
> 
> How should I go about debugging this?

Find the feature you load/activate in your init files which causes
this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 09:11:01 GMT) Full text and rfc822 format available.

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

From: William Rankin <william <at> bydasein.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 7 Mar 2020 19:10:09 +1000

> On 7 Mar 2020, at 6:00 pm, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> How should I go about debugging this?
> 
> Find the feature you load/activate in your init files which causes
> this?

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 will of course endeavour to isolate my init away from the problem to
confirm it's not the culprit, but given that the problem only occurs
after hours of use and maybe a couple of times a week, this is going to
mean some time before I can give any useful confirmation.

Given the impending release of 27.1 maybe there are other avenues I can
check too?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 11:06:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: William Rankin <william <at> bydasein.com>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 07 Mar 2020 13:04:58 +0200
> From: William Rankin <william <at> bydasein.com>
> Date: Sat, 7 Mar 2020 19:10:09 +1000
> Cc: 39967 <at> debbugs.gnu.org
> 
> > Find the feature you load/activate in your init files which causes
> > this?
> 
> 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.

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

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.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 12:18:02 GMT) Full text and rfc822 format available.

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

From: William Rankin <william <at> bydasein.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 7 Mar 2020 22:16:56 +1000

> On 7 Mar 2020, at 9:04 pm, Eli Zaretskii <eliz <at> gnu.org> 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??





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 13:07:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: William Rankin <william <at> bydasein.com>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 07 Mar 2020 15:06:37 +0200
> From: William Rankin <william <at> bydasein.com>
> Date: Sat, 7 Mar 2020 22:16:56 +1000
> Cc: 39967 <at> debbugs.gnu.org
> 
> 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.

If this happens when Emacs is idle, the first suspect is some idle
timer you have running.  The variable timer-idle-list holds the list
of the active idle timers, so look there for some hints.

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

Unlikely, since this only runs when you invoke mark-word.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 13:48:02 GMT) Full text and rfc822 format available.

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

From: William Rankin <william <at> bydasein.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 7 Mar 2020 23:47:24 +1000
> On 7 Mar 2020, at 11:06 pm, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> If this happens when Emacs is idle, the first suspect is some idle
> timer you have running.  The variable timer-idle-list holds the list
> of the active idle timers, so look there for some hints.

This is what made me suspect jit-lock, because of the 5 sec idle timer 
followed by jumping at 0.5 secs intervals.

Here's my timer list:

           0.37     0.01 blink-cursor-timer-function
           6.59        - undo-auto--boundary-timer
          47.03     1.00 display-time-event-handler
   *       0.00        t show-paren-function
   *       0.50        t #f(compiled-function () #<bytecode 0x41903951> [jit-lock--antiblink-grace-timer jit-lock-context-fontify])
   *       0.50  :repeat blink-cursor-start
   *       1.00        t which-key--update
   *       5.00        t jit-lock-stealth-fontify

Could the sporadic nature hint at the byte-compiled function that calls 
jit-lock-context-fontify? (Also I see jit-lock-antiblink-grace is new 
in 27.)

Of course there's also which-key, so I've turned that off for the time
being.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 07 Mar 2020 15:34:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: William Rankin <william <at> bydasein.com>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 07 Mar 2020 17:32:55 +0200
> From: William Rankin <william <at> bydasein.com>
> Date: Sat, 7 Mar 2020 23:47:24 +1000
> Cc: 39967 <at> debbugs.gnu.org
> 
> 
>            0.37     0.01 blink-cursor-timer-function
>            6.59        - undo-auto--boundary-timer
>           47.03     1.00 display-time-event-handler
>    *       0.00        t show-paren-function
>    *       0.50        t #f(compiled-function () #<bytecode 0x41903951> [jit-lock--antiblink-grace-timer jit-lock-context-fontify])
>    *       0.50  :repeat blink-cursor-start
>    *       1.00        t which-key--update
>    *       5.00        t jit-lock-stealth-fontify
> 
> Could the sporadic nature hint at the byte-compiled function that calls 
> jit-lock-context-fontify? (Also I see jit-lock-antiblink-grace is new 
> in 27.)

How about changing jit-lock-context-time to something like 1.5, and
checking whether this affects the frequency of the jumps in any way?

I looked at the code of the involved functions, and couldn't spot any
place where they move point without wrapping that in save-excursion.
But maybe I'm missing something -- can you see any suspects?

Also, do you have any features enabled which could perform a redisplay
triggered by point movement?  If you do, perhaps they cause point to
be displayed when Emacs doesn't expect that.

Btw, in your original description you said when point jumps, it's
outside of the current window -- but if so, how do you see that it
jumps, when the cursor is not shown?

And finally, what happens if you disable the blink-cursor-mode?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Tue, 10 Mar 2020 10:30:02 GMT) Full text and rfc822 format available.

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

From: William Rankin <william <at> bydasein.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Tue, 10 Mar 2020 20:29:09 +1000
On Sun, Mar 08 2020, Eli Zaretskii wrote:
> How about changing jit-lock-context-time to something like 1.5, and
> checking whether this affects the frequency of the jumps in any way?

Good idea. I think the difficulty with debugging this is how difficult it will
be for me to solve without reliably reproducing it.

> I looked at the code of the involved functions, and couldn't spot any
> place where they move point without wrapping that in save-excursion.
> But maybe I'm missing something -- can you see any suspects?

The only thing (I'm guessing here) is that the macro
with-buffer-prepared-for-jit-lock uses inhibit-point-motion-hooks which is
marked obsolete since Emacs-25.1; but there's nothing in the NEWS about this.

Also manually calling jit-lock-context-fontify or jit-lock-stealth-fontify
doesn't move point :/

> Also, do you have any features enabled which could perform a redisplay
> triggered by point movement?  If you do, perhaps they cause point to
> be displayed when Emacs doesn't expect that.

This would only be on post-command-hook or with cursor-sensor-mode activated
right? As far as I can tell I don't have any buffers with cursor-sensor-mode
active, and this is the value of post-command-hook in an elisp buffer:

  (jit-lock--antiblink-post-command eldoc-schedule-timer t)
  Local in buffer binder.el; global value is
  (global-font-lock-mode-check-buffers global-eldoc-mode-check-buffers
    global-page-break-lines-mode-check-buffers)

> Btw, in your original description you said when point jumps, it's
> outside of the current window -- but if so, how do you see that it
> jumps, when the cursor is not shown?

Sorry, I was unclear. I only meant that e.g. if the window shows buffer lines
500 - 580 then point may jump to position 250, i.e. beyond the window
boundaries, and the window scrolls to keep point visible. So essentially the
window jumps around to follow point jumping around.

> And finally, what happens if you disable the blink-cursor-mode?

Done. Still a waiting game...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Wed, 02 Feb 2022 18:25:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: William Rankin <william <at> bydasein.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Wed, 02 Feb 2022 19:24:10 +0100
William Rankin <william <at> bydasein.com> writes:

>> And finally, what happens if you disable the blink-cursor-mode?
>
> Done. Still a waiting game...

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Are you still seeing this odd behaviour in more recent Emacs versions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 02 Feb 2022 18:25:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Fri, 04 Feb 2022 05:07:02 GMT) Full text and rfc822 format available.

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

From: "Paul W. Rankin" <pwr <at> bydasein.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Fri, 04 Feb 2022 15:06:05 +1000
On 2022-02-03 04:24, Lars Ingebrigtsen wrote:
> 
> Are you still seeing this odd behaviour in more recent Emacs versions?

I haven't seen this in a while; I think it was isolated to that 
version/build.
Thanks for following up.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#39967; Package emacs. (Sat, 05 Feb 2022 06:35:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Paul W. Rankin" <pwr <at> bydasein.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 39967 <at> debbugs.gnu.org
Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?
Date: Sat, 05 Feb 2022 07:34:43 +0100
"Paul W. Rankin" <pwr <at> bydasein.com> writes:

>> Are you still seeing this odd behaviour in more recent Emacs
>> versions?
>
> I haven't seen this in a while; I think it was isolated to that
> version/build.

Thanks; I'm closing this bug report, then.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 39967 <at> debbugs.gnu.org and William Rankin <william <at> bydasein.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 05 Feb 2022 06:36:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 05 Mar 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 53 days ago.

Previous Next


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