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

From: [email-masked] (N. Jackson)
Date: Tue, 16 Jun 2015 22:59:51 -0300

At 12:03 -0300 on Tuesday 2015-06-16, Eli Zaretskii wrote:

> Please try the patch below. If it solves the problem, I will install
> it shortly. Please try both an optimized and a non-optimized build, if
> you can afford that.
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 7c15330..1e2f1b26 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -15094,7 +15094,8 @@ enum
>  	    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);
> +	  } while (IT_CHARPOS (it) < ZV
> +		   && line_bottom_y (&it1) - start_y < amount_to_scroll);
>  	}
>  
>        /* If STARTP is unchanged, move it down another screen line.  */

Short version: I am reasonably confident that the infloop does not occur
with this patch.

Longer version:

I say "reasonably" because I still do not have an exact recipe to
trigger the infloop. It seems to be some interaction with the layout of
the web page, the height of the images and the height of the window. I
was unsuccessful reproducing the problem with C-u 12 M-x
split-window-below and then opening the web page in Eww, possibly
because the height required to reproduce the problem is not exactly 11
(the way Gnus sets the window heights maybe gives a fractional size to
the upper window).

In any case, the infloop is not too hard to trigger by moving around the
window and scrolling. With my own (unoptimised build), in four trials I
was able to trigger the infloop in 5 minutes 16 seconds, 57 seconds, 48
seconds, and 58 seconds from the time I clicked the email link that
opened the offending web page. (The time was less after I got more
aggressive with the interface.) With the Fedora 21 build, in four trials
I triggered the infloop in 2:17, 1:38, 0:49, and 0:43.

With the patch, in my unoptimised build, configured with

    ./configure --prefix=/home/nlj/local/  --enable-checking='yes,glyphs' CFLAGS="-O0 -g3 -ggdb"

, I was unable to trigger an infloop in over seven and a half minutes of
aggressive interaction with the window displaying the offending web
page.

Also with the patch, in a build configured with the Fedora 21 build's
settings:

    ./configure --build=x86_64-redhat-linux-gnu  --host=x86_64-redhat-linux-gnu --program-prefix=  --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr  --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc  --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64  --libexecdir=/usr/libexec --localstatedir=/var  --sharedstatedir=/var/lib --mandir=/usr/share/man  --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png  --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3  --with-gpm=no build_alias=x86_64-redhat-linux-gnu  host_alias=x86_64-redhat-linux-gnu CFLAGS="-DMAIL_USE_LOCKF -O2 -g  -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2  -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4  -grecord-gcc-switches -m64 -mtune=generic" LDFLAGS="-Wl,-z,relro" 

, I was unable to trigger an infloop in over ten minutes of aggressive
interaction with the window displaying the offending web page.