Subject: bug#27210: 25.2; Recovering loaddefs.el with desktop-mode hangs when linum is on

From: [email-masked]
Date: Sat, 03 Jun 2017 13:43:45 -0400

tags 27210 confirmed
quit

Pierre Neidhardt <[email-masked]> writes:

> On 17-06-03 17:56:00, Eli Zaretskii wrote:
>> >
>> > With the following init file:
>> >
>> > 	(desktop-save-mode 1)
>> > 	(global-linum-mode)
>> >
>> > I visit "/usr/share/emacs/25.2/lisp/loaddefs.el" and everything is fine.
>> > I save the desktop session with `desktop-save-in-desktop-dir' and kill
>> > Emacs.
[...]
>> > and Emacs hangs for minutes at least, possibly forever, becoming a CPU hog. I
>> > then have to kill Emacs.
>
>> Can you try building the Emacs master branch?  If my guess is correct,
>> this problem will not exist there.
>
> I just did and the issue is still there.
>
> I am sorry I forgot to mention that the issue only happens when running `emacs --daemon`.

I can reproduce this, the problem seems to be that window-start and
window-end give the same answers as point-min and point-max respectively
when in daemon mode.  This causes linum-update-window to make overlays
for every line in the buffer.

    (defun linum-update-window (win)
      "Update line numbers for the portion visible in window WIN."
      (goto-char (window-start win))
      (let ((line (line-number-at-pos))
            (limit (window-end win t))
        [...]
        ;; Create an overlay (or reuse an existing one) for each
        ;; line visible in this window, if necessary.
        (while (and (not (eobp)) (< (point) limit))

(gdb) p current_buffer->name_ 
$11 = XIL(0x2ecd214)
(gdb) xpr
Lisp_String
$12 = (struct Lisp_String *) 0x2ecd210
"loaddefs.el"
(gdb) n
1614	  buf = w->contents;
(gdb) 
1615	  CHECK_BUFFER (buf);
(gdb) 
1616	  b = XBUFFER (buf);
(gdb) 
1618	  if (! NILP (update)
(gdb) 
1619	      && (windows_or_buffers_changed
(gdb) 
1628	      && !(noninteractive || FRAME_INITIAL_P (WINDOW_XFRAME (w))))
(gdb) 
1662	    XSETINT (value, BUF_Z (b) - w->window_end_pos);
(gdb) 
1664	  return value;
(gdb) p value
$13 = make_number(1203513)
(gdb) xbacktrace
"window-end" (0xffff74f0)
"linum-update-window" (0xffff7d68)
"mapc" (0xffff7f88)
"linum-update" (0xffff86d0)
"linum-after-scroll" (0xffff8ec8)
"set-window-buffer" (0xffff9130)
"switch-to-buffer" (0xffff98e0)
"desktop-restore-file-buffer" (0xffffa0f0)
"desktop-create-buffer" (0xffffa930)
"eval-buffer" (0xffffae80)
"load-with-code-conversion" (0xffffb698)
"load" (0xffffbac8)
"desktop-read" (0xffffc370)
0x1510fd0 PVEC_COMPILED
"run-hooks" (0xffffccd0)
"command-line" (0xffffdb48)
"normal-top-level" (0xffffe3c0)