Subject: bug#25176: 26.0.50; nxml-mode hangs on first failing isearch after opening big file

From: Kevin Brubeck Unhammer <[email-masked]>
Date: Sun, 11 Dec 2016 22:48:17 +0100

Hi,

I think I've found a strange performance bug in nxml-mode, where the
first failing isearch will hang and require a C-g, whereas the second
(for the same string or any other) is near-instant.

To reproduce:

$ wget https://unhammer.org/k/nxml-isearch-hang.xml
$ emacs -Q nxml-isearch-hang.xml
# Then in emacs, answer yes and isearch for e.g. "x-x":
y C-s x - x

Now it'll hang, and require a C-g. A subsequent search, however, is
instant.

If I rename the file to end in .txt so it opens in fundamental-mode, I
don't get the hang. This is quite annoying, since I very often open huge
xml files and immediately start isearching for something, meaning I
always have to wait for the hang, C-g, then search again.

In GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2016-12-09 built on lgw01-51
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:	Ubuntu 16.04.1 LTS

Configured using:
 'configure --build=x86_64-linux-gnu --prefix=/usr
 '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
 '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
 --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
 --program-suffix=-snapshot --with-modules=yes --with-x=yes
 --with-x-toolkit=gtk3 --with-xwidgets=yes 'CFLAGS=-g -O2
 -fstack-protector-strong -Wformat -Werror=format-security'
 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS LIBSYSTEMD

Important settings:
  value of $LANG: nn_NO.UTF-8
  value of $XMODIFIERS: 
  locale-coding-system: utf-8