Subject: bug#20808: 24.5; Emacs looping with 100% CPU at line 15287 (?) of xdisp.c

From: [email-masked] (N. Jackson)
Date: Mon, 15 Jun 2015 12:42:57 -0300

At 16:46 -0300 on Sunday 2015-06-14, Eli Zaretskii wrote:

> And I understand you have set scroll-conservatively to a value larger
> than 100, is that true?

Indeed, yes:

    scroll-conservatively is a variable defined in `C source code'.
    Its value is 101
    Original value was 0

> The loop where Emacs is evidently inflooping is this:
>
> 	  start_y = line_bottom_y (&it1);
> 	  do {
> 	    RESTORE_IT (&it, &it, it1data);
> 	    move_it_by_lines (&it, 1);
> 	    SAVE_IT (it1, it, it1data);
> 	  } while (line_bottom_y (&it1) - start_y < amount_to_scroll);

Yes, that's right:

    15283             do {
    15284               RESTORE_IT (&it, &it, it1data);
    15285               move_it_by_lines (&it, 1);
    15286               SAVE_IT (it1, it, it1data);
    15287             } while (line_bottom_y (&it1) - start_y < amount_to_scroll);

> So what I'd like to know is values of the following variables:
>
>   it.current
>   it.current_y
>   it.max_ascent
>   it.max_descent
>   it.method
>   start_y
>
> With the exception of the last variable, which should stay fixed
> during the loop, please step through the loop a few times, and show
> the values of the above variables for each iteration through the loop.

At 12:03 -0300 on Monday 2015-06-15, Eli Zaretskii wrote:

> And one more: the value of ZV (a.k.a. current_buffer->zv).

I have results from the (presumably optimised) Fedora 21 build and also
from my own build which I finally managed to get to infloop the same
way.

It's not clear to me if GDB prints out the statement it just executed or
the statement that it will execute next, so I looked at the values of
the variables after each step of the loop to be sure I didn't miss
anything.

The variables don't change, and after a few spins through the loop,
I set watchpoints on them and `finish' and there was no sign of them
changing after about five minutes, after which I did a C-c.

For the Fedora 21 build (the variables don't change):

    (gdb) p it.current
    $11 = {pos = {charpos = 0, bytepos = 0}, overlay_string_index = 0, string_pos = {charpos = 0, bytepos = 0}, dpvec_index = 0}
    (gdb) p it.current_y  
    $12 = 0
    (gdb) p it.max_ascent 
    $13 = 0
    (gdb) p it.max_descent
    $14 = 0
    (gdb) p it.method
    $15 = GET_FROM_BUFFER
    (gdb) p start_y
    No symbol "start_y" in current context.
    (gdb) p ZV
    No symbol "ZV" in current context.
    (gdb) p current_buffer->zv
    $27 = 3255

For my build (again the variables don't change):

    (gdb) p it.current
    $20 = {pos = {charpos = 2840, bytepos = 2841}, overlay_string_index = -1, string_pos = {charpos = -1, bytepos = -1}, dpvec_index = -1}
    (gdb) p it.current_y
    $21 = 270
    (gdb) p it.ascent 
    $22 = 11
    (gdb) p it.descent
    $23 = 3
    (gdb) p it.method
    $24 = GET_FROM_BUFFER
    (gdb) p start_y
    $25 = 270
    (gdb) p ZV
    $34 = 2840
    (gdb) p current_buffer->zv
    $35 = 2840

I hope this helps, and I await further instructions should further
debugging be worthwhile.

Thanks.