Subject: bug#22287: 25.1.50; Sudden jumping point in buffer

From: "Stefan-W. Hahn" <[email-masked]>
Date: Sun, 3 Jan 2016 21:51:04 +0100

Mail von David Engster, Sun, 03 Jan 2016 at 16:47:29 +0100:

Hello,

> That's interesting. Why do timers run here at all? Since your
> 'out:'-Message comes before that, it is clear that this is not because
> of `accept-process-output'.

I extended semanticdb-save-all-db-idle a little bit and replaced the
semantic-exit-on-input macro with its code:

,----
| (defun semanticdb-save-all-db-idle ()
|   "Save all semantic tag databases from idle time.
| Exit the save between databases if there is user input."
|   (semantic-safe "Auto-DB Save: %S"
|     ;; FIXME: Use `while-no-input'?
|     ;;    (save-excursion
|     (let ((start (point)))
|       (setq my-msg t)
|       (message "*** sem start: buffer %s %d" (buffer-name) (point))
|       (let ((semantic-current-input-throw-symbol 'semanticdb-idle-save)
|             (semantic--on-input-start-marker (point-marker)))
|         (catch 'semanticdb-idle-save
|           ;; ,@forms)))
|           ;;(semantic-exit-on-input 'semanticdb-idle-save
|           (mapc (lambda (db)
|                   (message "*** sem: buffer %s %d" (buffer-name) (point))
|                   (when
|                       (and semantic-current-input-throw-symbol
|                            (or
|                             (let
|                                 ((pos
|                                   (point))
|                                  rc)
|                               (setq rc
|                                     (input-pending-p))
|                               (message "*** input: rc=%s %d %d" rc pos
|                                        (point))
|                               rc)
|                             (let ((pos (point))
|                                   rc)
|                               (with-current-buffer
|                                   (marker-buffer semantic--on-input-start-marker)
|                                 (save-excursion
|                                   (goto-char semantic--on-input-start-marker)
|                                   (setq rc (accept-process-output))))
|                               (message "*** out: rc=%s %d %d" rc pos (point))
|                               rc)))
|                     (message "throw %d"
|                              (point))
|                     (throw semantic-current-input-throw-symbol 'semanticdb-idle-save))
|                   (let ((pos (point)))
|                     (semanticdb-save-db db t)
|                     (if (/= pos (point))
|                         (message "*** db %s %d->%d" db pos (point)))
|                     ))
|                 semanticdb-database-list)
|           (message "*** sem end: buffer %s %d->%d" (buffer-name) start (point))
|           )
|         (message "*** sem end2: buffer %s %d->%d" (buffer-name) start (point))
|         (message "*** sem end2: timer %s" timer-list)
|         (message "*** sem end2: idle-timer %s" timer-idle-list)
|         (message "*** sem end2: post-command-hook %s" post-command-hook)
|         (message "*** sem end2: pre-command-hook %s" pre-command-hook)
|         )
|       (setq my-msg nil)
|       )
|     ))
`----

This shows:
- With my-msg I tried to show running timers inside semantic-exit-on-input.
  There where just calls to jit-lock-deferred-fontify, but never when
  jumping point.
- point is never moving inside the "catch" ("sem end" has never shown up)
- every time point was jumping was with "sem end2"

> before calling `accept-process-output'. This here seems to be something
> different, in that not Semantic is moving point but some timer (which
> does not mean there isn't a bug in Semantic here).

> This makes sense as I cannot reproduce it here with
> 
>   emacs -Q -f semantic-mode
> 
> I'd suggest that you also start with 'emacs -Q' and activate minor-modes
> you're using until you see the bug. Reducing `auto-save-interval' might

That was a good hint. I sat it to 20 and it happened more often.

When started with

     emacs -Q

I got following minor-modes enabled in "intervals.c" buffer:

- abbrev-mode
- transient-mark-mode
- line-number-mode
- auto-compression-mode
- auto-encryption-mode
- auto-composition-mode
- blink-cursor-mode
- font-lock-mode
- global-font-lock-mode
- file-name-shadow-mode
- menu-bar-mode
- tool-bar-mode
- mouse-wheel-mode
- electric-indent-mode
- global-eldoc-mode
- tooltip-mode
- semantic-mode
- semantic-idle-scheduler-mode
- global-semantic-idle-scheduler-mode
- global-semanticdb-minor-mode
- diff-auto-refine-mode
- global-semantic-decoration-mode
- semantic-decoration-mode)

I tried to shut them off one after another. The minimum set of switched on
minor modes where the error happened was:

- menu-bar-mode
- semantic-mode
- semantic-idle-scheduler-mode
- global-semantic-idle-scheduler-mode
- global-semanticdb-minor-mode)

Output of one of moving point errors:

,----
| *** sem start: buffer intervals.c 49510
| *** sem: buffer intervals.c 49510
| *** input: rc=nil 49510 49510
| *** out: rc=nil 49510 49510
| *** sem: buffer intervals.c 49510
| *** input: rc=nil 49510 49510
| *** out: rc=nil 49510 49510
| *** sem: buffer intervals.c 49510
| *** input: rc=nil 49510 49510
| *** out: rc=nil 49510 49510
| *** sem: buffer intervals.c 49510
| *** input: rc=nil 49510 49510
| *** out: rc=nil 49510 49510
| *** sem: buffer intervals.c 49510
| *** input: rc=nil 49510 49510
| *** out: rc=nil 49510 49510
| *** sem: buffer intervals.c 49510
| *** input: rc=nil 49510 49510
| *** out: rc=nil 49510 49510
| *** sem end2: buffer intervals.c 49510->49391
| *** sem end2: timer nil
| *** sem end2: idle-timer ([nil 0 1 0 t semantic-idle-scheduler-function nil idle 0] [nil 0 60 0 t semantic-idle-scheduler-work-function nil idle 0])
| *** sem end2: post-command-hook (diff-post-command-hook t)
| *** sem end2: pre-command-hook nil
`----

When switching semantic-mode off, the error seems not to be reproducible.

This should it be for today.

With kind regards,
Stefan

-- 
Stefan-W. Hahn                          It is easy to make things.
                                        It is hard to make things simple.